wiki - Page 2 of 35 - workassis

Spring boot: skip unit test

mvn clean package -DskipTests=true

mvn clean install -DskipTests=true

 

By bm on June 13, 2017 | Spring boot | A comment?

Spring boot : Run Spring boot application from command line

Run Spring boot application from command line

//Using the Maven plugin

mvn spring-boot:run


//Passing environment 

mvn spring-boot:run -Drun.jvmArguments="-Dspring.profiles.active=production"

//Running as a packaged application (You can use mvn clean install OR  mvn clean package to generate jar file)

java -jar your-project-folder/target/myproject-0.0.1-SNAPSHOT.jar

ref: –spring-boot-docs

 

By bm on June 12, 2017 | Spring boot | A comment?

spring boot : Accept date in URL param

Option 1

	@RequestMapping(value = "/{customerId}/data/{startDate}/{endDate}", method = RequestMethod.GET)
	public void getUserData(@PathVariable("customerId") long customerId,
			@PathVariable("startDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date startDate,
			@PathVariable("endDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date endDate, HttpServletRequest request,
			HttpServletResponse response) throws Exception {


		//Your logic will be here :)
		
	}

 

Option 2

public void getmyData(@RequestParam("date") 
                            @DateTimeFormat(pattern = "dd-mm-yyyy") LocalDate date) {
        //Do stuff
    }

 

By bm on | Spring boot | A comment?

spring boot : Send http response code

Add packages

import javax.servlet.http.HttpServletRequest; //optional
import javax.servlet.http.HttpServletResponse;

Add status with response

	@RequestMapping(value = "/{customerId}", method = RequestMethod.GET)
	public void getMydata(@PathVariable("customerId") int customerId, HttpServletRequest request,
			HttpServletResponse response) throws Exception {

			if (is != null) {
				
				//-----Success part-----
				
				
				
			} else {
				 response.setStatus(HttpServletResponse.SC_NO_CONTENT);
			}

	}

 

By bm on | Spring boot | A comment?

Shell script: Convert text to lowercase and uppercase

Shell script

s="Hello World!" 

echo $s  # Hello World!

a=${s,,}
echo $a  # hello world!

b=${s^^}
echo $b  # HELLO WORLD!

O/p

By bm on March 23, 2017 | ubuntu | 1 comment
Tags: ,

Virtualbox SSH between host and guest

Virtualbox SSH

Here I am running a virtual box inside my windows machine, and I have installed Ubuntu in my virtual box

Step 1. Start your  virtual box Ubuntu and get the guest ip, (You can use ifconfig command to get the details)

fig 1: (inside virtual box Ubuntu terminal)

configsshinvirtualboxlinuxwithnat1

step 2. shutdown/turn off the virtual box Ubuntu and get the virtual machine properties

go to Network

select NAT

expand Adanced

Click on Port Forwarding button

In the port forwarding rules click add (right top + button)

For the role name you can give any name

Protocal : TCP

Host IP : 127.0.1.1

Host port : 22

Gust IP : <give your virtual box ip address taken from step 1 >

press ok and finish

configsshinvirtualboxlinuxwithnat  3. Start your virtual machine and connect to vm Ubuntu using ssh

open your ssh supporting software (Here i am using git bash)

ssh <your ubuntu username>@127.0.1.1

and give your user password

configsshinvirtualboxlinuxwithnat3

Now you will be able to access your gust machine

 

Note:- You should install ssh server in vb os

eg

sudo apt install openssh-server

 

By bm on November 29, 2016 | Virtualbox | A comment?
Tags: ,

Ajax
Android
Android XML
ArrayList
Browser
Codeigniter
Css
Drupal 8