Aries' Blog

Freestyle technical blog

SpringBoot app start / stop script

Start / Stop script for springboot app on linux, with following features:

  1. Start script won’t create new instance if the app already running
  2. Run the app in background and forward all console output to “log.log”

1. Start Script


if [ -f "./PID" ]; then
  echo "PID exists, app already running"
  nohup java -jar ./MyApp-0.1-SNAPSHOT.jar > log.log 2>&1 &
  echo $! > PID

2. Stop Script


kill `cat ./PID`
rm PID

Trace dependency origin in maven pom

In large maven project sometime it’s hard to trace the origin of a dependency’s version (Especially with multi-level parent pom / spring-boot parent). In this case below command can help.

1. For maven version 3.2.0+

Use help:effective-pom with -Dverbose=true flag

mvn help:effective-pom -Dverbose=true

Sample output

        <groupId>org.springframework.boot</groupId>  <!-- org.springframework.boot:spring-boot-dependencies:2.0.5.RELEASE, line 208 -->
        <artifactId>spring-boot</artifactId>  <!-- org.springframework.boot:spring-boot-dependencies:2.0.5.RELEASE, line 209 -->
        <version>2.0.5.RELEASE</version>  <!-- org.springframework.boot:spring-boot-dependencies:2.0.5.RELEASE, line 210 -->

Debug spring-boot app with IntelliJ IDEA community

In intelliJ IDEA, if you debug a spring boot app by right-clicking the “main” class (e.g. and select “Debug”, ClassNotFoundException may happen.

As suggested on stackoverflow, we should use maven goal spring-boot:run to debug spring boot app.

Also we should disable maven “forkmode”, otherwise breakpoint won’t work (I think we could use remote debugging with forkmode but haven’t tried).

Setup maven debug with “spring-boot:run” goal

  1. In IntelliJ menu, select Run -> Edit Configurations
  2. Click the “+” sign to Add New Configuration, select Maven in the dropdown
  3. Use spring-boot:run -Dfork=false as the Command line
  4. Click OK to save the configuration and debug as usual

Install Docker on Ubuntu

There are 2 ways to install Docker engine on Ubuntu, one is easy but the version not as updated. The other one is more complex but is the official way in

1. Easy Way (For older docker version)

Note the package name

sudo apt-get install

2. Hard Way (For latest docker version)

Follow this guide.

  1. Uninstall old versions
    sudo apt-get remove docker docker-engine containerd runc
  2. Setup apt-repository for docker
  3. Install Docker engine
    sudo apt-get update
    sudo apt-get install docker-ce docker-ce-cli
  4. Verify that Docker engine is installed correctly
    sudo docker run hello-world

Bonus – Install docker-compose

Follow this docker-compose guide.

  1. Download current stable release of Docker Compose
    sudo curl -L "$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  2. Apply executable permissions to the binary
    sudo chmod +x /usr/local/bin/docker-compose
  3. Test installation
    docker-compose --version