I am building a Spring Cloud Config server and I use the property server.contextPath: /configServer but I also want my server to respond with 200 on any request to /ping (not /configServer/ping).
Is there any way to bypass the contextPath property for a specific RestController (or any other way to achieve that)?
Thanks.
I found the solution to my problem:
There is the spring property spring.cloud.config.server.prefix which does exactly what I was looking for. This prefix is like contextPath but only for the configuration server hence I can write my custom controller for /ping mapping while configuration server serves all request to /configServer.
UPDATE:
sample code:
This is the controller to respond to /ping
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
#RestController
public class PingController {
#RequestMapping(value = "/ping", method = RequestMethod.GET)
public void respondToPing() {
return;
}
}
in the application properties (i use yml):
...
spring:
profiles:
active: native
cloud:
config:
server:
prefix: /api/configuration
...
I cannot share the whole config file but it worths mentioning it doesn't include the server.contextPath property.
This will result in these mappings:
2018-11-14 15:45:53.208 INFO 13412 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/ping],methods=[GET]}" onto public void com.coral.epos2.config.server.controllers.PingController.respondToPing()
2018-11-14 15:45:53.215 INFO 13412 --- [ 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)
2018-11-14 15:45:53.218 INFO 13412 --- [ 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)
2018-11-14 15:45:53.333 INFO 13412 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/configuration/encrypt],methods=[POST]}" onto public java.lang.String org.springframework.cloud.config.server.encryption.EncryptionController.encrypt(java.lang.String,org.springframework.http.MediaType)
2018-11-14 15:45:53.336 INFO 13412 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/configuration/encrypt/{name}/{profiles}],methods=[POST]}" onto public java.lang.String org.springframework.cloud.config.server.encryption.EncryptionController.encrypt(java.lang.String,java.lang.String,java.lang.String,org.springframework.http.MediaType)
2018-11-14 15:45:53.339 INFO 13412 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/configuration/decrypt/{name}/{profiles}],methods=[POST]}" onto public java.lang.String org.springframework.cloud.config.server.encryption.EncryptionController.decrypt(java.lang.String,java.lang.String,java.lang.String,org.springframework.http.MediaType)
2018-11-14 15:45:53.342 INFO 13412 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/configuration/decrypt],methods=[POST]}" onto public java.lang.String org.springframework.cloud.config.server.encryption.EncryptionController.decrypt(java.lang.String,org.springframework.http.MediaType)
2018-11-14 15:45:53.345 INFO 13412 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/configuration/encrypt/status],methods=[GET]}" onto public java.util.Map<java.lang.String, java.lang.Object> org.springframework.cloud.config.server.encryption.EncryptionController.status()
2018-11-14 15:45:53.348 INFO 13412 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/configuration/key],methods=[GET]}" onto public java.lang.String org.springframework.cloud.config.server.encryption.EncryptionController.getPublicKey()
...
My pom.xml
<?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">
<artifactId>config-server</artifactId>
<groupId>foivaras</groupId>
<modelVersion>4.0.0</modelVersion>
<name>configuration server</name>
<packaging>jar</packaging>
<version>develop-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Camden.SR6</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>4.7</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Hope that helps.
Maybe add a ServletRegistrationBean. This would allow you to listen for requests coming to /ping or for /*.
#Bean
public ServletRegistrationBean pingServletDispatcher() {
DispatcherServlet dispatcherServlet = new DispatcherServlet();
//XmlWebApplicationContext applicationContext = new XmlWebApplicationContext();
//applicationContext.setConfigLocation("classpath:/META-INF/spring/webmvc-context.xml");
//dispatcherServlet.setApplicationContext(applicationContext);
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(dispatcherServlet, "/ping/*" /* or /* / */);
servletRegistrationBean.setName("ping");
return servletRegistrationBean;
}
Related
For running the Spring web-application as Maven project, I need to add
spring-boot-starter-tomcat as dependency in pom.xml. But for gradle project it is not required in build.gradle. Why is that so? I am running both in Intellij.
Running the Spring web-application as Maven project, if scope is specified as 'provided' in spring-boot-starter-tomcat dependency, the application starts without error and just ends. I need to comment scope 'provided' to run continuously as server. This is the console output on scope 'provided':
Starting CourseidServiceApplication using Java 17.0.4 on ES-LAPTOP-876 with PID 21352 (C:\ProjWS\courseid-service\target\classes started by kakoli.sen in C:\ProjWS\courseid-service)
2022-08-14 10:28:06.919 INFO 21352 --- [ main] c.p.l.s.s.c.CourseidServiceApplication : No active profile set, falling back to 1 default profile: "default"
2022-08-14 10:28:07.574 INFO 21352 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-08-14 10:28:07.641 INFO 21352 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 56 ms. Found 1 JPA repository interfaces.
2022-08-14 10:28:08.300 INFO 21352 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2022-08-14 10:28:08.354 INFO 21352 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.10.Final
2022-08-14 10:28:08.520 INFO 21352 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2022-08-14 10:28:08.686 INFO 21352 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2022-08-14 10:28:09.050 INFO 21352 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2022-08-14 10:28:09.066 INFO 21352 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
2022-08-14 10:28:09.787 INFO 21352 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2022-08-14 10:28:09.795 INFO 21352 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2022-08-14 10:28:10.309 INFO 21352 --- [ main] c.p.l.s.s.c.CourseidServiceApplication : Started CourseidServiceApplication in 3.86 seconds (JVM running for 4.392)
After
2022-08-14 10:28:10.317 INFO 21352 --- [ionShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2022-08-14 10:28:10.320 INFO 21352 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2022-08-14 10:28:10.333 INFO 21352 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
========
pom.xml
========
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.pearson.ltg.sms.services.courseid</groupId>
<artifactId>courseid-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>courseid-service</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I don't think you need a tomcat starter here:
You already have
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
By default it plugs the embedded tomcat and spring MVC so no need to other dependencies
Open Spring Initializr project and create a sample project, specify the webmvc and see what does it produce...
I'm creating a configuration server using spring cloud and when I'm trying to get my configuration info from git using http://localhost:8071/licensing-service/dev it works perfectly.
But when I specify the active profile dev in my configuration-client application
it sends request on http://localhost:8071/licensing-service/default where as it should be sending request on http://localhost:8071/licensing-service/dev.
Here is the debug info from configuration-client:
2022-08-03 01:44:11.999 INFO 11828 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8071
2022-08-03 01:44:12.000 DEBUG 11828 --- [ main] o.s.web.client.RestTemplate : HTTP GET http://localhost:8071/licensing-service/default
2022-08-03 01:44:12.003 DEBUG 11828 --- [ main] o.s.web.client.RestTemplate : Accept=[application/json, application/*+json]
2022-08-03 01:44:12.677 DEBUG 11828 --- [ main] o.s.web.client.RestTemplate : Response 200 OK
2022-08-03 01:44:12.678 DEBUG 11828 --- [ main] o.s.web.client.RestTemplate : Reading to [org.springframework.cloud.config.environment.Environment]
2022-08-03 01:44:12.679 INFO 11828 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=licensing-service, profiles=[default], label=null, version=a846a28be97b432d11b0ec2a9476fa3c933ac5fc, state=null
2022-08-03 01:44:12.680 INFO 11828 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-configClient'}, BootstrapPropertySource {name='bootstrapProperties-https://github.com/DaveySC/config.git/file:C:\Users\hrisa\AppData\Local\Temp\config-repo-12695370095836324476\licensing-service.yaml'}]
2022-08-03 01:44:12.687 INFO 11828 --- [ main] c.e.l.LicensingServiceApplication : The following 1 profile is active: "dev"
2022-08-03 01:44:12.687 DEBUG 11828 --- [ main] o.s.boot.SpringApplication : Loading source class com.example.licensingsevice.LicensingServiceApplication,class org.springframework.cloud.bootstrap.BootstrapApplicationListener$BootstrapMarkerConfiguration
2022-08-03 01:44:12.708 INFO 11828 --- [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://localhost:8071
2022-08-03 01:44:12.708 INFO 11828 --- [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Located environment: name=licensing-service, profiles=[dev], label=null, version=a846a28be97b432d11b0ec2a9476fa3c933ac5fc, state=null
2022-08-03 01:44:12.709 DEBUG 11828 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#50d3bf39
2022-08-03 01:44:13.482 INFO 11828 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-08-03 01:44:13.495 DEBUG 11828 --- [ main] o.s.b.a.AutoConfigurationPackages : #EnableAutoConfiguration was declared on a class in the package 'com.example.licensingsevice'. Automatic #Repository and #Entity scanning is enabled.
2022-08-03 01:44:13.538 INFO 11828 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 46 ms. Found 1 JPA repository interfaces.
2022-08-03 01:44:13.750 INFO 11828 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=ed5de582-c803-356a-a378-fc5af6eb571e
2022-08-03 01:44:14.113 DEBUG 11828 --- [ main] .s.b.w.e.t.TomcatServletWebServerFactory : Code archive: C:\Users\hrisa\.m2\repository\org\springframework\boot\spring-boot\2.7.2\spring-boot-2.7.2.jar
2022-08-03 01:44:14.113 DEBUG 11828 --- [ main] .s.b.w.e.t.TomcatServletWebServerFactory : Code archive: C:\Users\hrisa\.m2\repository\org\springframework\boot\spring-boot\2.7.2\spring-boot-2.7.2.jar
2022-08-03 01:44:14.113 DEBUG 11828 --- [ main] .s.b.w.e.t.TomcatServletWebServerFactory : None of the document roots [src/main/webapp, public, static] point to a directory and will be ignored.
2022-08-03 01:44:14.133 INFO 11828 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-08-03 01:44:14.141 INFO 11828 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-08-03 01:44:14.142 INFO 11828 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.65]
2022-08-03 01:44:14.295 INFO 11828 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-08-03 01:44:14.295 DEBUG 11828 --- [ main] w.s.c.ServletWebServerApplicationContext : Published root WebApplicationContext as ServletContext attribute with name [org.springframework.web.context.WebApplicationContext.ROOT]
2022-08-03 01:44:14.295 INFO 11828 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1586 ms
2022-08-03 01:44:14.390 ERROR 11828 --- [ main] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'webMvcMetricsFilter' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.class]: Unsatisfied dependency expressed through method 'webMvcMetricsFilter' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'simpleMeterRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimpleMetricsExportAutoConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourcePoolMetadataMeterBinder' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsAutoConfiguration$DataSourcePoolMetadataMetricsConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourcePoolMetadataMeterBinder' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
2022-08-03 01:44:14.410 INFO 11828 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2022-08-03 01:44:14.419 WARN 11828 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2022-08-03 01:44:14.443 DEBUG 11828 --- [ main] ConditionEvaluationReportLoggingListener :
Here is the main class of this server, pom and bootstrap.yml
package com.example.configurationserver;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
import org.springframework.cloud.context.config.annotation.RefreshScope;
#SpringBootApplication
#EnableConfigServer
#RefreshScope
public class ConfigurationServerApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigurationServerApplication.class, args);
}
}
pom.xml
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>configuration-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>configuration-server</name>
<description>configuration-server</description>
<properties>
<java.version>17</java.version>
<spring-cloud.version>2021.0.3</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.7.1</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
bootstrap.yml
spring:
application:
name: configuration-server
profiles:
active: git
cloud:
config:
server:
git:
default-label: main
uri: https://github.com/DaveySC/config.git
boot:
admin:
client:
url: http://localhost:8080
server:
port: 8071
management:
endpoints:
web:
exposure:
include: "*"
Here are the client files:
pom.xml
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>licensing-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>licensing-service</name>
<description>licensing-sevice</description>
<properties>
<java.version>17</java.version>
<spring-cloud.version>2021.0.3</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
bootstrap.yml
spring:
application:
name: licensing-service
config:
import: optional:configserver:http://localhost:8071
profiles:
active: dev
debug: true
And here is the exception i get:
description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (the profiles dev are currently active).
What should i do to make my app send request on the url that depends on the active profile client app?
I have been looking over countless posts on here and other sites to no avail.
I am attempting to run my cucumber integration tests against a running, local version of my spring boot app as part of my CI pipeline. I am constantly getting "Connection Refused" which would lead you to believe the app isn't starting up, however, if I try to start my app up normally using the port provided when the tests are at a breakpoint, it will tell me this port is already being used.
pom.xml:
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.busybee</groupId>
<artifactId>backend</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>backend</name>
<description>Busy Bees backend API</description>
<properties>
<java.version>1.8</java.version>
<cucumber-version>1.2.5</cucumber-version>
<unit-tests.skip>false</unit-tests.skip>
<integration-tests.skip>false</integration-tests.skip>
</properties>
<profiles>
<!-- The Configuration of the unit profile. This is the default profile -->
<profile>
<id>unit-test</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<build.profile.id>unit-test</build.profile.id>
<skip.integration.tests>true</skip.integration.tests>
<skip.unit.tests>false</skip.unit.tests>
</properties>
</profile>
<!-- The Configuration of the integration-test profile -->
<profile>
<id>integration-test</id>
<properties>
<build.profile.id>integration-test</build.profile.id>
<skip.integration.tests>false</skip.integration.tests>
<skip.unit.tests>true</skip.unit.tests>
</properties>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>5.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java8</artifactId>
<version>5.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>5.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-spring</artifactId>
<version>5.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.197</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- Run *Test.java tests as unit tests during test phase -->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<configuration>
<skipTests>${skip.unit.tests}</skipTests>
</configuration>
</plugin>
<!-- Run *IT.java tests as integration tests during verify phase -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.21.0</version>
<configuration>
<skipTests>${skip.integration.tests}</skipTests>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
BackendApplication
#SpringBootApplication(exclude = { SecurityAutoConfiguration.class })
#EnableJpaRepositories
public class BackendApplication {
#Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
public static void main(String[] args) {
final SpringApplication springApplication =
new SpringApplication(BackendApplication.class);
// it is being added here for LOCAL run ONLY , spring profiles should be be run time parameters when run spring boot jar
springApplication.setDefaultProperties(Collections.singletonMap("spring.profiles.default","LOCAL"));
springApplication.addListeners(new ApplicationPidFileWriter());
springApplication.run(args);
}
}
Step defintions
public class GetNodeSteps extends CucumberBase {
ResponseEntity<Location> responseLoc;
#Before("#BeforeCreateLocation")
public void create_existing_location() throws Throwable {
Location location = generateLocation();
responseLoc = template.postForEntity("/location/register", location, Location.class);
if (responseLoc.getStatusCodeValue() == HttpStatus.BAD_REQUEST.value()) {
fail("Couldn't create location");
}
}
//Rest of steps omitted
CucumberBase
#SpringBootTest(classes = BackendApplication.class, webEnvironment = RANDOM_PORT)
#ContextConfiguration
public class CucumberBase {
#Autowired
public TestRestTemplate template;
#LocalServerPort
public int randomServerPort;
#Before
public void contextLoads() throws Exception {
}
}
FeaturesIT
#RunWith(Cucumber.class)
#CucumberOptions(features = "src/test/resources/features", glue = {"com.busybee.backend.integration"})
public class FeaturesIT {
}
Stack trace
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.4.RELEASE)
2020-05-27 17:49:49.787 INFO 20488 --- [ main] c.b.backend.integration.GetNodeSteps : Starting GetNodeSteps on Rob-Desktop with PID 20488 (started by Robert in C:\dir)
2020-05-27 17:49:49.791 INFO 20488 --- [ main] c.b.backend.integration.GetNodeSteps : The following profiles are active: test
2020-05-27 17:49:50.630 INFO 20488 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-05-27 17:49:50.694 INFO 20488 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 56ms. Found 4 JPA repository interfaces.
2020-05-27 17:49:51.183 INFO 20488 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-05-27 17:49:51.757 INFO 20488 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 0 (http)
2020-05-27 17:49:51.765 INFO 20488 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-05-27 17:49:51.766 INFO 20488 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.30]
2020-05-27 17:49:51.882 INFO 20488 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-05-27 17:49:51.882 INFO 20488 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2037 ms
2020-05-27 17:49:52.110 INFO 20488 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-05-27 17:49:52.184 INFO 20488 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.4.10.Final}
2020-05-27 17:49:52.323 INFO 20488 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-05-27 17:49:52.449 INFO 20488 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-05-27 17:49:52.601 INFO 20488 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-05-27 17:49:52.626 INFO 20488 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2020-05-27 17:49:53.369 INFO 20488 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-05-27 17:49:53.375 INFO 20488 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-05-27 17:49:53.967 WARN 20488 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-05-27 17:49:54.199 INFO 20488 --- [ main] pertySourcedRequestMappingHandlerMapping : Mapped URL path [/v2/api-docs] onto method [springfox.documentation.swagger2.web.Swagger2Controller#getDocumentation(String, HttpServletRequest)]
2020-05-27 17:49:54.391 INFO 20488 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-05-27 17:49:54.439 INFO 20488 --- [ main] o.s.b.a.w.s.WelcomePageHandlerMapping : Adding welcome page template: index
2020-05-27 17:49:54.728 INFO 20488 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
2020-05-27 17:49:54.749 INFO 20488 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
2020-05-27 17:49:54.774 INFO 20488 --- [ main] s.d.s.w.s.ApiListingReferenceScanner : Scanning for api listing references
2020-05-27 17:49:54.982 INFO 20488 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 58500 (http) with context path ''
2020-05-27 17:49:54.985 INFO 20488 --- [ main] c.b.backend.integration.GetNodeSteps : Started GetNodeSteps in 5.609 seconds (JVM running for 6.852)
Step failed
org.springframework.web.client.ResourceAccessException: I/O error on POST request for "http://localhost:58500/location/register": Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:751)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:677)
at org.springframework.web.client.RestTemplate.postForEntity(RestTemplate.java:452)
at org.springframework.boot.test.web.client.TestRestTemplate.postForEntity(TestRestTemplate.java:457)
at com.busybee.backend.integration.GetNodeSteps.create_existing_location(GetNodeSteps.java:48)
Appreciate any help that can be given, thanks.
I managed to figure it out, my H2 db wasn't being created by the SpringBootTestApplication as my test properties had:
spring.jpa.hibernate.ddl-auto=update
When it needed to be:
spring.jpa.hibernate.ddl-auto=create
After running the Main class, i am not able to get the output.
New to Spring Boot
Controller
#Controller
public class WelcomeController {
private static final String welcomemsg = "Welcome Mr. %s!";
#GetMapping("/welcome/user")
#ResponseBody
public Welcome welcomeUser(#RequestParam(name = "name", required = false, defaultValue = "Java Fan") String name)
{
return new Welcome(String.format(welcomemsg, name));
}
}
Main class
package com.beans.mainsrc;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication(scanBasePackages = { "com.beans" })
public class DemoApplication {
public static void main(String[] args)
{
SpringApplication.run(DemoApplication.class, args);
}
}
console detail on running the main class
2018-09-28 00:40:01.268 INFO 2304 --- [ main] com.beans.mainsrc.DemoApplication : Starting DemoApplication on DESKTOP-551C51M with PID 2304 (F:\springbootdemo\demo\target\classes started by sparsh in F:\springbootdemo\demo)
2018-09-28 00:40:01.273 INFO 2304 --- [ main] com.beans.mainsrc.DemoApplication : No active profile set, falling back to default profiles: default
2018-09-28 00:40:01.346 INFO 2304 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#3e08ff24: startup date [Fri Sep 28 00:40:01 IST 2018]; root of context hierarchy WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/C:/Users/sparsh/.m2/repository/org/springframework/spring-core/5.0.9.RELEASE/spring-core-5.0.9.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release
2018-09-28 00:40:02.370 INFO 2304 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-09-28 00:40:02.392 INFO 2304 --- [ main] com.beans.mainsrc.DemoApplication : Started DemoApplication in 1.67 seconds (JVM running for 2.23)
2018-09-28 00:40:02.396 INFO 2304 --- [ Thread-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#3e08ff24: startup date [Fri Sep 28 00:40:01 IST 2018]; root of context hierarchy
2018-09-28 00:40:02.398 INFO 2304 --- [ Thread-1] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
pom.xml
<?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>
<groupId>springboot</groupId>
<artifactId>springbootdemo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
<relativePath />
<!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Looks like your servlet container is not starting. Please try to add this maven dependency
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
You can remove these dependencies :
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
They are provided by the suggested starter.
I am building a very basic spring-boot service using the inbuild tomcat server.
Pom looks like this :
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!--<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>-->
<!--<dependency>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-starter-jdbc</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<!--<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
I am setting the port in the application.properties file as server.port=8089. There is one Ping URI added in the controller class as :
#RequestMapping("/ping")
#RestController
public class helloController {
#RequestMapping(method= RequestMethod.GET,produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<String> ping(){
return new ResponseEntity<>("Hello World Spring-boot app", HttpStatus.OK);
}
When I do a mvn clean package everything works fine and the build is a success. But when I run the application from the Main() this is what the log looks like :
2017-09-19 10:37:32.219 INFO 6436 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default
2017-09-19 10:37:32.290 INFO 6436 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#77f99a05: startup date [Tue Sep 19 10:37:32 PDT 2017]; root of context hierarchy
2017-09-19 10:37:33.782 INFO 6436 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-09-19 10:37:33.802 INFO 6436 --- [ main] com.example.demo.DemoApplication : Started DemoApplication in 2.043 seconds (JVM running for 2.802)
2017-09-19 10:37:33.802 INFO 6436 --- [ Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#77f99a05: startup date [Tue Sep 19 10:37:32 PDT 2017]; root of context hierarchy
2017-09-19 10:37:33.802 INFO 6436 --- [ Thread-2] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
The log is not showing what port the service is starting .
What else is to be done to start the service on the designated port and to keep the server up an running?
Solved this problem. Started the in built tomcat server using spring-boot:run option