VisualVM

How to Evaluate the Performance (CPU + Memory) of java Software:

java -Dcom.sun.management.jmxremote.port=9011 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -cp “.:../lib/*:../../../../lib/*” it.AppListener > /var/log/AppListener.log 2>&1 &

or
export JAVA_OPTS=”-server -Xms6144M -Xmx7168M -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false”

after set the port variable during the start up of the software, is possible to use to evaluate the situation this software

Linux command to check which process takes memory

ps aux  | awk '{print $6/1024 " MB\t\t" $11}'  | sort -n

 

Where to download VisualVM

Deploy a Spring Boot application under Tomcat Web Server Container

Higthligths:
@SpringBootApplication
public class Application extends SpringBootServletInitializer {

protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}

public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}

}

pom.xml

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
    </dependency>



</dependencies>

Spring boot provides option to deploy the application as a traditional war file in servlet 3.x(without web.xml)supporting tomcat server.Please see spring boot documentation for this. I will brief what you need to do here.

step 1 : modify pom.xml to change the packaging to war:(that you already did)

<packaging>war</packaging>

step 2 : change your dependency

    <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-tomcat</artifactId>
   </dependency>

to

<dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-tomcat</artifactId>
      <scope>provided</scope>
</dependency>

step 3 :modify your war name (if you need to avoid the version details appended with the war name) in pom.xml under <build> tag.

<build>
    <finalName>web-service</finalName>
.....

step 4 : run maven build to create war : clean install step 5 : deploy the generated war file web-service.war in tomcat and request url in browser http://<tomcat ip>:<tomcat port>/web-service/hello

 

here the project : http://gitlab.saic.it/root/spring-boot-war-tomcat