Monday, July 31, 2017

Information on the Executable JAR in a spring boot application built using Maven

To understand what happens, it is a good practice to extract and see what the files included in a executable JAR built using Maven. Here I'm using the JAR built in
[1] http://ajanthane.blogspot.com/2017/07/getting-started-with-spring-boot-sample.html.

When we extract the JAR, we will see the below structure.


Below is the summarized contents of the above folders.


When we check the MANIFEST-INF file, then we can identify which class get invoked as entry point. The main use of the MANIFEST-INF file is:

  • Define the entry point of the Application, make the Jar executable.
  • Add project dependency classpath.

Here, specifically when we look at the below two lines:

Main-Class: org.springframework.boot.loader.JarLauncher
Start-Class: org.test.springboot.Application

That means the first class which get invoked is org.springframework.boot.loader.JarLauncher and then only it will start the main class we have specified, in our case org.test.springboot.Application.

More information on this can be found at [2].
[2] https://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html

That's it...

Tuesday, July 25, 2017

Getting started with Spring Boot - Sample Rest Web Application with Explanation

Spring Boot is a spring module which help us to create spring applications without doing much configuration with the dependency management it has and also provides embedded Servlet container support. Some of the features of the spring boot extracted from the spring documentation states as below:

- Create stand-alone Spring applications
- Embed Tomcat, Jetty or Undertow directly ( no need to deploy WAR files )
- Provide opinionated 'starter' POMs to simplify your Maven configuration
- Automatically configure Spring whenever possible
- Provide production-ready features such as metrics, health checks and externalized configuration
- Absolutely no code generation and no requirement for XML configuration
Here, I'm going to create a simple Rest Web Application. Let's start with the pom.xml configuration. Here I'm considering that we already created the Maven Project using the Spring Tool Suite, which can be downloaded from [1].

1) In the pom.xml first we need to configure is the parent tag. In maven when we specify the parent tag, maven reads the parent POM from your local repository or external repositories and creates a POM by merging the information from parent and module POM. One reason to use a parent is that we have a central place to store information about versions of artifacts, compiler-settings etc. that should be used in all modules.

As the first step adding the parent as below:

 <!-- Parent pom providing dependency and plugin management for applications   
           built with Maven -->  
      <parent>  
           <groupId>org.springframework.boot</groupId>  
           <artifactId>spring-boot-starter-parent</artifactId>  
           <version>1.5.4.RELEASE</version>  
      </parent>  

Here, we are using the "spring-boot-starter-parent" as artifact and when we check this pom.xml from [2] https://github.com/spring-projects/spring-boot/blob/v1.5.4.RELEASE/spring-boot-starters/spring-boot-starter-parent/pom.xml

it will appear as below:
 <?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">  
      <modelVersion>4.0.0</modelVersion>  
      <parent>  
           <groupId>org.springframework.boot</groupId>  
           <artifactId>spring-boot-dependencies</artifactId>  
           <version>1.5.4.RELEASE</version>  
           <relativePath>../../spring-boot-dependencies</relativePath>  
      </parent>  
      <artifactId>spring-boot-starter-parent</artifactId>  
      <packaging>pom</packaging>  
      <name>Spring Boot Starter Parent</name>  
      <description>Parent pom providing dependency and plugin management for applications  
           built with Maven</description>  
      <url>http://projects.spring.io/spring-boot/</url>  
      <organization>  
           <name>Pivotal Software, Inc.</name>  
           <url>http://www.spring.io</url>  
      </organization>  
      <properties>  
           <java.version>1.6</java.version>  
           <resource.delimiter>@</resource.delimiter> <!-- delimiter that doesn't clash with Spring ${} placeholders -->  
           <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>  
           <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>  
           <maven.compiler.source>${java.version}</maven.compiler.source>  
           <maven.compiler.target>${java.version}</maven.compiler.target>  
      </properties>  
      <dependencyManagement>  
           <dependencies>  
                <dependency>  
                     <groupId>org.springframework</groupId>  
                     <artifactId>spring-core</artifactId>  
                     <version>${spring.version}</version>  
                     <exclusions>  
                          <exclusion>  
                               <groupId>commons-logging</groupId>  
                               <artifactId>commons-logging</artifactId>  
                          </exclusion>  
                     </exclusions>  
                </dependency>  
           </dependencies>  
      </dependencyManagement>  
      <build>  
           <!-- Turn on filtering by default for application properties -->  
           <resources>  
                <resource>  
                     <directory>${basedir}/src/main/resources</directory>  
                     <filtering>true</filtering>  
                     <includes>  
                          <include>**/application*.yml</include>  
                          <include>**/application*.yaml</include>  
                          <include>**/application*.properties</include>  
                     </includes>  
                </resource>  
                <resource>  
                     <directory>${basedir}/src/main/resources</directory>  
                     <excludes>  
                          <exclude>**/application*.yml</exclude>  
                          <exclude>**/application*.yaml</exclude>  
                          <exclude>**/application*.properties</exclude>  
                     </excludes>  
                </resource>  
           </resources>  
           <pluginManagement>  
                <plugins>  
                     <!-- Apply more sensible defaults for user projects -->  
                     <plugin>  
                          <groupId>org.apache.maven.plugins</groupId>  
                          <artifactId>maven-failsafe-plugin</artifactId>  
                          <executions>  
                               <execution>  
                                    <goals>  
                                         <goal>integration-test</goal>  
                                         <goal>verify</goal>  
                                    </goals>  
                               </execution>  
                          </executions>  
                     </plugin>  
                     <plugin>  
                          <groupId>org.apache.maven.plugins</groupId>  
                          <artifactId>maven-jar-plugin</artifactId>  
                          <configuration>  
                               <archive>  
                                    <manifest>  
                                         <mainClass>${start-class}</mainClass>  
                                         <addDefaultImplementationEntries>true</addDefaultImplementationEntries>  
                                    </manifest>  
                               </archive>  
                          </configuration>  
                     </plugin>  
                     <plugin>  
                          <groupId>org.apache.maven.plugins</groupId>  
                          <artifactId>maven-surefire-plugin</artifactId>  
                          <configuration>  
                               <includes>  
                                    <include>**/*Tests.java</include>  
                                    <include>**/*Test.java</include>  
                               </includes>  
                               <excludes>  
                                    <exclude>**/Abstract*.java</exclude>  
                               </excludes>  
                          </configuration>  
                     </plugin>  
                     <plugin>  
                          <groupId>org.apache.maven.plugins</groupId>  
                          <artifactId>maven-war-plugin</artifactId>  
                          <configuration>  
                               <failOnMissingWebXml>false</failOnMissingWebXml>  
                               <archive>  
                                    <manifest>  
                                         <mainClass>${start-class}</mainClass>  
                                         <addDefaultImplementationEntries>true</addDefaultImplementationEntries>  
                                    </manifest>  
                               </archive>  
                          </configuration>  
                     </plugin>  
                     <plugin>  
                          <groupId>org.codehaus.mojo</groupId>  
                          <artifactId>exec-maven-plugin</artifactId>  
                          <configuration>  
                               <mainClass>${start-class}</mainClass>  
                          </configuration>  
                     </plugin>  
                     <plugin>  
                          <groupId>org.apache.maven.plugins</groupId>  
                          <artifactId>maven-resources-plugin</artifactId>  
                          <version>2.6</version>  
                          <configuration>  
                               <delimiters>  
                                    <delimiter>${resource.delimiter}</delimiter>  
                               </delimiters>  
                               <useDefaultDelimiters>false</useDefaultDelimiters>  
                          </configuration>  
                     </plugin>  
                     <plugin>  
                          <groupId>pl.project13.maven</groupId>  
                          <artifactId>git-commit-id-plugin</artifactId>  
                          <executions>  
                               <execution>  
                                    <goals>  
                                         <goal>revision</goal>  
                                    </goals>  
                               </execution>  
                          </executions>  
                          <configuration>  
                               <verbose>true</verbose>  
                               <dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>  
                               <generateGitPropertiesFile>true</generateGitPropertiesFile>  
                               <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>  
                          </configuration>  
                     </plugin>  
                     <!-- Support our own plugin -->  
                     <plugin>  
                          <groupId>org.springframework.boot</groupId>  
                          <artifactId>spring-boot-maven-plugin</artifactId>  
                          <executions>  
                               <execution>  
                                    <goals>  
                                         <goal>repackage</goal>  
                                    </goals>  
                               </execution>  
                          </executions>  
                          <configuration>  
                               <mainClass>${start-class}</mainClass>  
                          </configuration>  
                     </plugin>  
                     <!-- Support shade packaging (if the user does not want to use our plugin) -->  
                     <plugin>  
                          <groupId>org.apache.maven.plugins</groupId>  
                          <artifactId>maven-shade-plugin</artifactId>  
                          <dependencies>  
                               <dependency>  
                                    <groupId>org.springframework.boot</groupId>  
                                    <artifactId>spring-boot-maven-plugin</artifactId>  
                                    <version>1.5.4.RELEASE</version>  
                               </dependency>  
                          </dependencies>  
                          <configuration>  
                               <keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>  
                               <createDependencyReducedPom>true</createDependencyReducedPom>  
                               <filters>  
                                    <filter>  
                                         <artifact>*:*</artifact>  
                                         <excludes>  
                                              <exclude>META-INF/*.SF</exclude>  
                                              <exclude>META-INF/*.DSA</exclude>  
                                              <exclude>META-INF/*.RSA</exclude>  
                                         </excludes>  
                                    </filter>  
                               </filters>  
                          </configuration>  
                          <executions>  
                               <execution>  
                                    <phase>package</phase>  
                                    <goals>  
                                         <goal>shade</goal>  
                                    </goals>  
                                    <configuration>  
                                         <transformers>  
                                              <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">  
                                                   <resource>META-INF/spring.handlers</resource>  
                                              </transformer>  
                                              <transformer implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer">  
                                                   <resource>META-INF/spring.factories</resource>  
                                              </transformer>  
                                              <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">  
                                                   <resource>META-INF/spring.schemas</resource>  
                                              </transformer>  
                                              <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>  
                                              <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">  
                                                   <mainClass>${start-class}</mainClass>  
                                              </transformer>  
                                         </transformers>  
                                    </configuration>  
                               </execution>  
                          </executions>  
                     </plugin>  
                </plugins>  
           </pluginManagement>  
      </build>  
 </project>  

2) When we observe the spring-boot-starter-parent pom.xml it is having the default java version as 1.6. As here I'm using java 1.8 I'm overiding that property in the child's pom.xml and adding the below:
 <properties>  
      <java.version>1.8</java.version>  
 </properties>  

3) Next is, as here we are going to create a Rest Web Application, we need to add the dependency "spring-boot-starter-web", which is used to as a Starter for building web, including RESTful, applications using Spring MVC. Uses Tomcat as the default embedded container.

The pom of this will look like below:
 <?xml version="1.0" encoding="UTF-8"?>  
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">  
      <modelVersion>4.0.0</modelVersion>  
      <parent>  
           <groupId>org.springframework.boot</groupId>  
           <artifactId>spring-boot-starters</artifactId>  
           <version>1.5.4.RELEASE</version>  
      </parent>  
      <artifactId>spring-boot-starter-web</artifactId>  
      <name>Spring Boot Web Starter</name>  
      <description>Starter for building web, including RESTful, applications using Spring  
           MVC. Uses Tomcat as the default embedded container</description>  
      <url>http://projects.spring.io/spring-boot/</url>  
      <organization>  
           <name>Pivotal Software, Inc.</name>  
           <url>http://www.spring.io</url>  
      </organization>  
      <properties>  
           <main.basedir>${basedir}/../..</main.basedir>  
      </properties>  
      <dependencies>  
           <dependency>  
                <groupId>org.springframework.boot</groupId>  
                <artifactId>spring-boot-starter</artifactId>  
           </dependency>  
           <dependency>  
                <groupId>org.springframework.boot</groupId>  
                <artifactId>spring-boot-starter-tomcat</artifactId>  
           </dependency>  
           <dependency>  
                <groupId>org.hibernate</groupId>  
                <artifactId>hibernate-validator</artifactId>  
           </dependency>  
           <dependency>  
                <groupId>com.fasterxml.jackson.core</groupId>  
                <artifactId>jackson-databind</artifactId>  
           </dependency>  
           <dependency>  
                <groupId>org.springframework</groupId>  
                <artifactId>spring-web</artifactId>  
           </dependency>  
           <dependency>  
                <groupId>org.springframework</groupId>  
                <artifactId>spring-webmvc</artifactId>  
           </dependency>  
      </dependencies>  
 </project>  

By default, Spring Boot 1.5.4.RELEASE requires Java 7 and Spring Framework 4.3.9.RELEASE or above. If we want to override the spring.version then we can again add a property as below.

 <spring.version>4.3.10.RELEASE</spring.version>  

Now we are done with the pom.xml configurations. Finally our pom.xml will look as below:
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">  
      <modelVersion>4.0.0</modelVersion>  
      <groupId>org.test.springboot</groupId>  
      <artifactId>springbootapp</artifactId>  
      <version>0.0.1-SNAPSHOT</version>  
      <packaging>jar</packaging>  
      <name>springbootapp</name>  
      <!-- Parent pom providing dependency and plugin management for applications   
           built with Maven -->  
      <parent>  
           <groupId>org.springframework.boot</groupId>  
           <artifactId>spring-boot-starter-parent</artifactId>  
           <version>1.5.4.RELEASE</version>  
      </parent>  
      <!-- Overiding the java version as the default version in the parent pom   
           is 1.6 for compiling and spring version to 4.3.10 as the default is 4.3.9   
           based on the spring-boot-starter-parent 1.5.4.RELEASE -->  
      <properties>  
           <java.version>1.8</java.version>  
           <spring.version>4.3.10.RELEASE</spring.version>  
      </properties>  
      <dependencies>  
           <!-- Starter for building web, including RESTful, applications using Spring   
                MVC. Uses Tomcat as the default embedded container. -->  
           <dependency>  
                <groupId>org.springframework.boot</groupId>  
                <artifactId>spring-boot-starter-web</artifactId>  
           </dependency>  
      </dependencies>  
 </project>  

4) Now we are ready to create the controller. Below is the sample i have created.
 package org.test.springboot;  
 import org.springframework.web.bind.annotation.RequestMapping;  
 import org.springframework.web.bind.annotation.RequestMethod;  
 import org.springframework.web.bind.annotation.RestController;  
 @RestController  
 public class RestSampleController {  
      @RequestMapping(value = "/testRestApp", method = RequestMethod.GET)  
      public String testRestApplication() {  
           return "Successfully test REST Application - 1";  
      }  
 }  

Here used the below annotations:

@RestController : This is combination of @Controller and @ResponseBody.
@RequestMapping(value = "/testRestApp", method = RequestMethod.GET) : This defines that only GET requests should invoke the /testRestApp.

Actually what happens here is, when we specify @RestController then the request processing path will be as below image, which is similar to what we use with @Controller and @ResponseBody.



5) After done with the controller, the next is to create an Application class. which is the one who start the spring application we have created. Spring Boot provides  SpringApplication class to bootstrap a Spring application that will be started from a main() method using static SpringApplication.run method.

The sample class I have created as below:
 package org.test.springboot;  
 import org.springframework.boot.SpringApplication;  
 import org.springframework.boot.autoconfigure.SpringBootApplication;  
 @SpringBootApplication  
 public class Application {  
      public static void main(String[] args) {  
           SpringApplication.run(Application.class, args);  
      }  
 }  

Here when you see, I'm using @SpringBootApplication annotation. The explanation for the annotation from the spring document as below:

@SpringBootApplication is a convenience annotation that adds all of the following:
  • @Configuration tags the class as a source of bean definitions for the application context.
  • @EnableAutoConfiguration tells Spring Boot to start adding beans based on classpath settings, other beans, and various property settings.
  • Normally we would add @EnableWebMvc for a Spring MVC app, but Spring Boot adds it automatically when it sees spring-webmvc on the classpath. This flags the application as a web application and activates key behaviors such as setting up a DispatcherServlet.
  • @ComponentScan tells Spring to look for other components, configurations, and services in the hello package, allowing it to find the controllers.
  • The main() method uses Spring Boot’s SpringApplication.run() method to launch an application.
6) Now we are ready to run the application, follow the below screens.





Through the above method we have started the application through Spring Tool Suite, but for production environments, it's recommended to use executable JAR option. To create a executable jar, while building using maven, need to specify the build option as below:
 <build>  
      <plugins>  
           <!-- This is to create the executable jar -->  
           <plugin>  
                <groupId>org.springframework.boot</groupId>  
                <artifactId>spring-boot-maven-plugin</artifactId>  
           </plugin>  
      </plugins>  
 </build>  

Now our updated pom.xml will be as below:
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">  
      <modelVersion>4.0.0</modelVersion>  
      <groupId>org.test.springboot</groupId>  
      <artifactId>springbootapp</artifactId>  
      <version>0.0.1-SNAPSHOT</version>  
      <packaging>jar</packaging>  
      <name>springbootapp</name>  
      <!-- Parent pom providing dependency and plugin management for applications   
           built with Maven -->  
      <parent>  
           <groupId>org.springframework.boot</groupId>  
           <artifactId>spring-boot-starter-parent</artifactId>  
           <version>1.5.4.RELEASE</version>  
      </parent>  
      <!-- Overiding the java version as the default version in the parent pom   
           is 1.6 for compiling and spring version to 4.3.10 as the default is 4.3.9   
           based on the spring-boot-starter-parent 1.5.4.RELEASE -->  
      <properties>  
           <java.version>1.8</java.version>  
           <spring.version>4.3.10.RELEASE</spring.version>  
      </properties>  
      <dependencies>  
           <!-- Starter for building web, including RESTful, applications using Spring   
                MVC. Uses Tomcat as the default embedded container. -->  
           <dependency>  
                <groupId>org.springframework.boot</groupId>  
                <artifactId>spring-boot-starter-web</artifactId>  
           </dependency>  
      </dependencies>  
      <build>  
           <plugins>  
                <!-- This is to create the executable jar -->  
                <plugin>  
                     <groupId>org.springframework.boot</groupId>  
                     <artifactId>spring-boot-maven-plugin</artifactId>  
                </plugin>  
           </plugins>  
      </build>  
 </project>  

After building the project, under target folder we can see two JARS as below:
 [INFO] Scanning for projects...  
 [INFO]                                       
 [INFO] ------------------------------------------------------------------------  
 [INFO] Building springbootapp 0.0.1-SNAPSHOT  
 [INFO] ------------------------------------------------------------------------  
 [INFO]   
 [INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ springbootapp ---  
 [INFO] Deleting /home/ajanthan/Documents/workspace-sts-3.9.0.RELEASE/springbootapp/target  
 [INFO]   
 [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ springbootapp ---  
 [INFO] Using 'UTF-8' encoding to copy filtered resources.  
 [INFO] skip non existing resourceDirectory /home/ajanthan/Documents/workspace-sts-3.9.0.RELEASE/springbootapp/src/main/resources  
 [INFO] skip non existing resourceDirectory /home/ajanthan/Documents/workspace-sts-3.9.0.RELEASE/springbootapp/src/main/resources  
 [INFO]   
 [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ springbootapp ---  
 [INFO] Changes detected - recompiling the module!  
 [INFO] Compiling 2 source files to /home/ajanthan/Documents/workspace-sts-3.9.0.RELEASE/springbootapp/target/classes  
 [INFO]   
 [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ springbootapp ---  
 [INFO] Using 'UTF-8' encoding to copy filtered resources.  
 [INFO] skip non existing resourceDirectory /home/ajanthan/Documents/workspace-sts-3.9.0.RELEASE/springbootapp/src/test/resources  
 [INFO]   
 [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ springbootapp ---  
 [INFO] Nothing to compile - all classes are up to date  
 [INFO]   
 [INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ springbootapp ---  
 [INFO] No tests to run.  
 [INFO]   
 [INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ springbootapp ---  
 [INFO] Building jar: /home/ajanthan/Documents/workspace-sts-3.9.0.RELEASE/springbootapp/target/springbootapp-0.0.1-SNAPSHOT.jar  
 [INFO]   
 [INFO] --- spring-boot-maven-plugin:1.5.4.RELEASE:repackage (default) @ springbootapp ---  
 [INFO]   
 [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ springbootapp ---  
 [INFO] Using 'UTF-8' encoding to copy filtered resources.  
 [INFO] skip non existing resourceDirectory /home/ajanthan/Documents/workspace-sts-3.9.0.RELEASE/springbootapp/src/main/resources  
 [INFO] skip non existing resourceDirectory /home/ajanthan/Documents/workspace-sts-3.9.0.RELEASE/springbootapp/src/main/resources  
 [INFO]   
 [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ springbootapp ---  
 [INFO] Nothing to compile - all classes are up to date  
 [INFO]   
 [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ springbootapp ---  
 [INFO] Using 'UTF-8' encoding to copy filtered resources.  
 [INFO] skip non existing resourceDirectory /home/ajanthan/Documents/workspace-sts-3.9.0.RELEASE/springbootapp/src/test/resources  
 [INFO]   
 [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ springbootapp ---  
 [INFO] Nothing to compile - all classes are up to date  
 [INFO]   
 [INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ springbootapp ---  
 [INFO] No tests to run.  
 [INFO] Skipping execution of surefire because it has already been run for this configuration  
 [INFO]   
 [INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ springbootapp ---  
 [INFO]   
 [INFO] --- spring-boot-maven-plugin:1.5.4.RELEASE:repackage (default) @ springbootapp ---  
 [INFO]   
 [INFO] --- maven-install-plugin:2.5.2:install (default-install) @ springbootapp ---  
 [INFO] Installing /home/ajanthan/Documents/workspace-sts-3.9.0.RELEASE/springbootapp/target/springbootapp-0.0.1-SNAPSHOT.jar to /home/ajanthan/.m2/repository/org/test/springboot/springbootapp/0.0.1-SNAPSHOT/springbootapp-0.0.1-SNAPSHOT.jar  
 [INFO] Installing /home/ajanthan/Documents/workspace-sts-3.9.0.RELEASE/springbootapp/pom.xml to /home/ajanthan/.m2/repository/org/test/springboot/springbootapp/0.0.1-SNAPSHOT/springbootapp-0.0.1-SNAPSHOT.pom  
 [INFO] ------------------------------------------------------------------------  
 [INFO] BUILD SUCCESS  
 [INFO] ------------------------------------------------------------------------  
 [INFO] Total time: 9.946 s  
 [INFO] Finished at: 2017-07-25T22:28:16+05:30  
 [INFO] Final Memory: 26M/206M  
 [INFO] ------------------------------------------------------------------------  


Now if we execute the below command, we can start the application through the console.
 ajanthan@ajanthan-Lenovo:~/Documents/workspace-sts-3.9.0.RELEASE/springbootapp/target$ java -jar springbootapp-0.0.1-SNAPSHOT.jar   
  .  ____     _      __ _ _  
  /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \  
 ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \  
  \\/ ___)| |_)| | | | | || (_| | ) ) ) )  
  ' |____| .__|_| |_|_| |_\__, | / / / /  
  =========|_|==============|___/=/_/_/_/  
  :: Spring Boot ::    (v1.5.4.RELEASE)  
 2017-07-25 22:30:32.093 INFO 23388 --- [      main] org.test.springboot.Application    : Starting Application v0.0.1-SNAPSHOT on ajanthan-Lenovo with PID 23388 (/home/ajanthan/Documents/workspace-sts-3.9.0.RELEASE/springbootapp/target/springbootapp-0.0.1-SNAPSHOT.jar started by ajanthan in /home/ajanthan/Documents/workspace-sts-3.9.0.RELEASE/springbootapp/target)  
 2017-07-25 22:30:32.106 INFO 23388 --- [      main] org.test.springboot.Application    : No active profile set, falling back to default profiles: default  
 2017-07-25 22:30:32.259 INFO 23388 --- [      main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5387f9e0: startup date [Tue Jul 25 22:30:32 IST 2017]; root of context hierarchy  
 2017-07-25 22:30:34.958 INFO 23388 --- [      main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)  
 2017-07-25 22:30:35.034 INFO 23388 --- [      main] o.apache.catalina.core.StandardService  : Starting service [Tomcat]  
 2017-07-25 22:30:35.036 INFO 23388 --- [      main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.15  
 2017-07-25 22:30:35.381 INFO 23388 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]    : Initializing Spring embedded WebApplicationContext  
 2017-07-25 22:30:35.382 INFO 23388 --- [ost-startStop-1] o.s.web.context.ContextLoader      : Root WebApplicationContext: initialization completed in 3128 ms  
 2017-07-25 22:30:35.641 INFO 23388 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]  
 2017-07-25 22:30:35.648 INFO 23388 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean  : Mapping filter: 'characterEncodingFilter' to: [/*]  
 2017-07-25 22:30:35.649 INFO 23388 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]  
 2017-07-25 22:30:35.649 INFO 23388 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean  : Mapping filter: 'httpPutFormContentFilter' to: [/*]  
 2017-07-25 22:30:35.649 INFO 23388 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean  : Mapping filter: 'requestContextFilter' to: [/*]  
 2017-07-25 22:30:36.389 INFO 23388 --- [      main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5387f9e0: startup date [Tue Jul 25 22:30:32 IST 2017]; root of context hierarchy  
 2017-07-25 22:30:36.554 INFO 23388 --- [      main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/testRestApp],methods=[GET]}" onto public java.lang.String org.test.springboot.RestSampleController.testRestApplication()  
 2017-07-25 22:30:36.564 INFO 23388 --- [      main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)  
 2017-07-25 22:30:36.566 INFO 23388 --- [      main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)  
 2017-07-25 22:30:36.626 INFO 23388 --- [      main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]  
 2017-07-25 22:30:36.627 INFO 23388 --- [      main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]  
 2017-07-25 22:30:36.716 INFO 23388 --- [      main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]  
 2017-07-25 22:30:37.103 INFO 23388 --- [      main] o.s.j.e.a.AnnotationMBeanExporter    : Registering beans for JMX exposure on startup  
 2017-07-25 22:30:37.506 INFO 23388 --- [      main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)  
 2017-07-25 22:30:37.534 INFO 23388 --- [      main] org.test.springboot.Application    : Started Application in 6.19 seconds (JVM running for 7.114)  



That's it...


Monday, July 3, 2017

How to set title for the Terminal in Ubuntu 17.04

1) Go to .bashrc file by executing the below command. Here I'm running the command under /home/ajanthan location.
 ajanthan@ajanthan-Lenovo:~$ sudo vi .bashrc  

2) The add the below code segment and save the changes.
 #Below is to set the terminal title.  
 set-title(){  
  ORIG=$PS1  
   TITLE="\e]2;$@\a"  
    PS1=${ORIG}${TITLE}  
 }  

3) Now execute the below command.


That's it...