Spring Boot Application taking 30-45 minutes to getting started - java

I have deployed stand alone jar on Linux server in production about 6 month ago. Its starting in about few seconds.
But when I deploy a newly builded jar on same server. It takes around 30-45 minutes for getting started.
Due to this I am not able to change any thing on existing setup.
I tried to start a Hello World spring boot app on same server. Its also taking 2 minutes for getting started.
Hello World App Logs:
[support#kbla180303 ~]$ java -jar /app/kpam/kpam-test.jar
Inside Main
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.4.RELEASE)
2019-05-09 13:26:42.606 INFO 1656 --- [ main] com.kmbl.kpam.KpamTest1Application : Starting KpamTest1Application v0.0.1-SNAPSHOT on kbla180303 with PID 1656 (/app/kpam/kpam-test.jar started by support in /home/support)
2019-05-09 13:26:43.110 INFO 1656 --- [ main] com.kmbl.kpam.KpamTest1Application : No active profile set, falling back to default profiles: default
2019-05-09 13:26:50.058 INFO 1656 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#531d72ca: startup date [Thu May 09 13:26:50 IST 2019]; root of context hierarchy
2019-05-09 13:27:52.515 INFO 1656 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2019-05-09 13:27:53.905 INFO 1656 --- [ main] com.kmbl.kpam.KpamTest1Application : Started KpamTest1Application in 122.87 seconds (JVM running for 164.207)
Exit Main
2019-05-09 13:27:53.907 INFO 1656 --- [ Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#531d72ca: startup date [Thu May 09 13:26:50 IST 2019]; root of context hierarchy
2019-05-09 13:27:53.910 INFO 1656 --- [ Thread-2] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown

I have updated the spring boot version from 1.5.4.RELEASE to 2.1.4.RELEASE. Now application is starting in few seconds.
But still not found the root cause for this issue.

Related

my springboot application embered tomcat started is very slowly

this is the startup log in this picture
21:20:45,691 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator#28c97a5 - Registering current configuration as safe fallback point
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.12.RELEASE)
2021-01-06 21:20:46,346 [main] INFO com.pingan.smartcity.scw.whapply.WhApplyApplication - Starting WhApplyApplication v1.0-SNAPSHOT on izxs801ql7o8q7dbxyv64jz with PID 11576 (/opt/data/app/h5/whapply-xm-1.0-SNAPSHOT.jar started by root in /opt/data/app/h5)
2021-01-06 21:20:46,349 [main] DEBUG com.pingan.smartcity.scw.whapply.WhApplyApplication - Running with Spring Boot v2.1.12.RELEASE, Spring v5.1.13.RELEASE
2021-01-06 21:20:46,349 [main] INFO com.pingan.smartcity.scw.whapply.WhApplyApplication - The following profiles are active: prod
2021-01-06 21:20:47,511 [main] WARN org.mybatis.spring.mapper.ClassPathMapperScanner - No MyBatis mapper was found in '[com.pingan.smartcity.scw.whapply]' package. Please check your configuration.
2021-01-06 21:20:47,550 [main] INFO org.springframework.data.repository.config.RepositoryConfigurationDelegate - Multiple Spring Data modules found, entering strict repository configuration mode!
2021-01-06 21:20:47,552 [main] INFO org.springframework.data.repository.config.RepositoryConfigurationDelegate - Bootstrapping Spring Data Redis repositories in DEFAULT mode.
2021-01-06 21:20:47,596 [main] INFO org.springframework.data.repository.config.RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 30ms. Found 0 Redis repository interfaces.
2021-01-06 21:20:48,110 [main] INFO o.s.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$f5a22d6c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-01-06 21:36:15,587 [main] INFO org.springframework.boot.web.embedded.tomcat.TomcatWebServer - Tomcat initialized with port(s): 8899 (http)
2021-01-06 21:36:15,608 [main] INFO org.apache.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8899"]
2021-01-06 21:36:15,622 [main] INFO org.apache.catalina.core.StandardService - Starting service [Tomcat]
2021-01-06 21:36:15,622 [main] INFO org.apache.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/9.0.30]
2021-01-06 21:36:15,710 [main] INFO org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext
2021-01-06 21:36:15,710 [main] INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 929305 ms
As shown in the picture above, It takes 10 minutes to start my springboot application, This is very abnormal, what's the problem '

Demonstrating microservices in spring and eclipse is not working

I am trying to build a proof of concept for microservices in java (eclipse) using Spring libraries and following this tutorial.
Due to certain restrictions, I am not using Maven, but I rather downloaded the following jar files manually and imported them to my java project.
My java code is very simple as the following:
package hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
#RestController
#SpringBootApplication
#EnableAutoConfiguration
public class HelloWorld {
#RequestMapping("/")
//http://localhost:port/
String hello()
{
return "Hello World!!!";
}
public static void main (String[] args) throws Exception
{
SpringApplication.run(HelloWorld.class,args);
}
}
The problem is: When I run the code, the server does NOT start, but no errors are there, except the following output, and the application shuts down instantly:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.0.RELEASE)
2019-08-29 09:41:17.999 INFO 14096 --- [ main] hello.HelloWorld : Starting HelloWorld on HQTPM146609D with PID 14096 (D:\Ramesh\ADMWorkspace\HelloWorldMicroservice\build\classes started by abdallah.alhodaly in D:\Ramesh\ADMWorkspace\HelloWorldMicroservice)
2019-08-29 09:41:18.002 INFO 14096 --- [ main] hello.HelloWorld : No active profile set, falling back to default profiles: default
2019-08-29 09:41:18.078 INFO 14096 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#3d36e4cd: startup date [Thu Aug 29 09:41:18 GST 2019]; root of context hierarchy
2019-08-29 09:41:19.408 INFO 14096 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2019-08-29 09:41:19.426 INFO 14096 --- [ main] hello.HelloWorld : Started HelloWorld in 1.86 seconds (JVM running for 2.504)
2019-08-29 09:41:19.430 INFO 14096 --- [ Thread-3] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#3d36e4cd: startup date [Thu Aug 29 09:41:18 GST 2019]; root of context hierarchy
2019-08-29 09:41:19.432 INFO 14096 --- [ Thread-3] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
How can I fix my code so that the message Hello World!!! is displayed on the web page? Thank You.
Update: Following the below answer, I set the context of my application to WebApplicationType.SERVLET. Now, I am getting the following errors:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.0.RELEASE)
2019-08-29 11:03:28.515 INFO 9416 --- [ main] hello.HelloWorld : Starting HelloWorld on HQTPM146609D with PID 9416 (D:\Ramesh\ADMWorkspace\HelloWorldMicroservice\build\classes started by abdallah.alhodaly in D:\Ramesh\ADMWorkspace\HelloWorldMicroservice)
2019-08-29 11:03:28.518 INFO 9416 --- [ main] hello.HelloWorld : No active profile set, falling back to default profiles: default
2019-08-29 11:03:28.616 INFO 9416 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#62e136d3: startup date [Thu Aug 29 11:03:28 GST 2019]; root of context hierarchy
2019-08-29 11:03:29.521 WARN 9416 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
2019-08-29 11:03:29.534 INFO 9416 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-08-29 11:03:29.542 ERROR 9416 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:155) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at hello.HelloWorld.main(HelloWorld.java:29) [classes/:na]
Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getWebServerFactory(ServletWebServerApplicationContext.java:204) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:178) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:152) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
... 6 common frames omitted
In main class, you need write "SpringApplication.run(HelloWorldApplication.class,args);"
Your application context is wrong, it should of web application context. To fix this try either of these
setApplicationContextClass(…) or setWebApplicationType(WebApplicationType) using SpringApplication.

Java: Eclipse console doesn't display Spring Controller information

When I run my spring boot application in eclipse 4.7.3 IDE, the console doesn't display the information about the rest controller. Nevertheless the controller is working when I test it with browser.
It is just a "Hello World" application:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class HelloWorldSpringBootApp {
public static void main(String[] args) {
SpringApplication.run(HelloWorldSpringBootApp.class, args);
}
}
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
#RestController
public class HelloWorldController {
#RequestMapping(value = "/")
public String helo() {
return "Hello World!";
}
}
Output:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.4.RELEASE)
2019-04-28 09:08:33.768 INFO 2208 --- [ main] c.infotech.app.HelloWorldSpringBootApp : Starting HelloWorldSpringBootApp on OfficeLaptop01 with PID 2208 (C:\Users\Admin\eclipse-workspace4.7.3a\Sprang\HelloWorldSpringBoot\target\classes started by Admin in C:\Users\Admin\eclipse-workspace4.7.3a\Sprang\HelloWorldSpringBoot)
2019-04-28 09:08:33.775 INFO 2208 --- [ main] c.infotech.app.HelloWorldSpringBootApp : No active profile set, falling back to default profiles: default
2019-04-28 09:08:34.852 INFO 2208 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-04-28 09:08:34.873 INFO 2208 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-04-28 09:08:34.873 INFO 2208 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.17]
2019-04-28 09:08:34.978 INFO 2208 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-04-28 09:08:34.978 INFO 2208 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1157 ms
2019-04-28 09:08:35.183 INFO 2208 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-04-28 09:08:35.348 INFO 2208 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2019-04-28 09:08:35.351 INFO 2208 --- [ main] c.infotech.app.HelloWorldSpringBootApp : Started HelloWorldSpringBootApp in 1.904 seconds (JVM running for 2.561)
As above it just display until "Started HelloWorldSpringBootApp in 1.904 seconds" without the request mapping status & mapped URL path info. Why?
The log output was changed in Spring 2.1. That changelog states that
If you are trying to debug an application and you want to restore
Spring Boot 2.0 style logging you should add the following to your
application.properties
logging.level.web=debug
This change however does not output what I would expect given this RestController
#RestController
public class HelloWorldController {
#RequestMapping(value = "/hello")
public String hello() {
return "Hello World!";
}
}
If I set the log level to trace it gives the expected output (though not in the exact same way as Spring Boot 2.1).
10:53:26.427 [main] TRACE o.s.w.s.m.m.a.RequestMappingHandlerMapping -
c.i.e.d.r.HelloWorldController:
{ /hello}: hello()
The requirement for trace log level is most likely due to a change in Spring Framework 5.1 (see release note)

Multi-context spring-boot application: how to define standard spring-boot properties for each child context

There is good question about ability to add multiple tomcat connectors and bind them to separate controllers each.
The essense of Andy Wilkinson's good answer is here:
public static void main(String[] args) {
SpringApplicationBuilder parentBuilder
= new SpringApplicationBuilder(ApplicationConfiguration.class);
parentBuilder.child(ServiceOneConfiguration.class)
.properties("server.port:8080").run(args);
parentBuilder.child(ServiceTwoConfiguration.class)
.properties("server.port:8081").run(args);
}
I want to go on this futher and ask another question:
Is there a way to make each child application context to read some child specific application properties with support of all standard spring-boot's features, like profile-suffix file names etc.
One hypothetical way to achieve it:
Have three separate property files:
application.properties
child1.properties
child2.properties
And have ability to set one file for each context.
But what is important to me, that they must support all spring-boot magic. For example, if I activate new profile like passing command line argument --spring.profiles.active=dev, then automagically not only these three files should be loaded (one for each context), but another set of files (if they exist) also should be loaded automatically:
application-dev.properties
child1-dev.properties
child2-dev.properties
Of course, these files should be searched at standard spring-boot's supported paths in defined order etc.
Is it possible out if the box of maybe with some coding?
Another hypothetical way to achieve it
Have only one application.properties file (with support for profiles etc), but somehow to map prefixed properties to unprefixed properties of child contexts.
Example:
child1.server.port=8081
child1.foo=bar
child2.server.port=8082
child2.foo=baz
First child context should see these properties like if they were just:
server.port=8081
foo=bar
Second child context should see these properties like if they were just:
server.port=8082
foo=baz
So, standard spring-boot's autoconfigurations will work and correctly set tomcat's port etc.
I am not looking for specific approach (but if you ask me, I'm leaning towards second approach), but any working out-of-the-box or achievable with minimum conding apporach will suffice me.
You can achieve your first suggestion using spring.config.name:
public static void main(String[] args) {
SpringApplicationBuilder parentBuilder =
new SpringApplicationBuilder(ParentApplication.class)
.web(WebApplicationType.NONE);
parentBuilder.run(args);
parentBuilder.child(ServiceOneConfiguration.class)
.properties("spring.config.name=child1").run(args);
parentBuilder.child(ServiceTwoConfiguration.class)
.properties("spring.config.name=child2").run(args);
}
You can then use child1{-profile}.properties and child2{-profile}.properties to configure service one and service two respectively.
For example, with server.port=8081 in child1.properties and server.port=8082 in child2.properties, you should see output similar to the following when starting an app that's using auto-configuration in the two child services and has a dependency on spring-boot-starter-web:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.2.RELEASE)
2019-01-22 13:38:09.690 INFO 80968 --- [ main] com.example.parent.ParentApplication : Starting ParentApplication on …
2019-01-22 13:38:09.692 INFO 80968 --- [ main] com.example.parent.ParentApplication : No active profile set, falling back to default profiles: default
2019-01-22 13:38:09.842 INFO 80968 --- [ main] com.example.parent.ParentApplication : Started ParentApplication in 0.371 seconds (JVM running for 0.644)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.2.RELEASE)
2019-01-22 13:38:10.046 INFO 80968 --- [ main] com.example.parent.ParentApplication : No active profile set, falling back to default profiles: default
2019-01-22 13:38:10.584 INFO 80968 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8081 (http)
2019-01-22 13:38:10.604 INFO 80968 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-01-22 13:38:10.605 INFO 80968 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.14]
2019-01-22 13:38:10.613 INFO 80968 --- [ main] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/awilkinson/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
2019-01-22 13:38:10.668 INFO 80968 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-01-22 13:38:10.668 INFO 80968 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 612 ms
2019-01-22 13:38:10.829 INFO 80968 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-01-22 13:38:10.981 INFO 80968 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8081 (http) with context path ''
2019-01-22 13:38:10.981 INFO 80968 --- [ main] com.example.parent.ParentApplication : Started ParentApplication in 0.955 seconds (JVM running for 1.784)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.2.RELEASE)
2019-01-22 13:38:11.003 INFO 80968 --- [ main] com.example.parent.ParentApplication : No active profile set, falling back to default profiles: default
2019-01-22 13:38:11.093 INFO 80968 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8082 (http)
2019-01-22 13:38:11.095 INFO 80968 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-01-22 13:38:11.096 INFO 80968 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.14]
2019-01-22 13:38:11.100 INFO 80968 --- [ main] o.a.c.c.C.[Tomcat-1].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-01-22 13:38:11.101 INFO 80968 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 97 ms
2019-01-22 13:38:11.135 INFO 80968 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-01-22 13:38:11.164 INFO 80968 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8082 (http) with context path ''
2019-01-22 13:38:11.165 INFO 80968 --- [ main] com.example.parent.ParentApplication : Started ParentApplication in 0.183 seconds (JVM running for 1.967)

Spring Boot Reference Guide - get 404 from app.groovy example

I follow Spring Boot Reference Guide and got this error
HTTP Status [404] – [Not Found]
Type Status Report
Message /
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Here is the code
#RestController
class ThisWillActuallyRun {
#RequestMapping("/")
String home() {
"Hello World!"
}
}
Command that I run.
spring run app.groovy
Console log that I got.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.4.RELEASE)
2017-07-21 14:37:37.474 INFO 47637 --- [ runner-0] o.s.boot.SpringApplication : Starting application on MacBook-Pro-2016.local with PID 47637 (started by moss in /Users/moss/java_ws/hello)
2017-07-21 14:37:37.477 INFO 47637 --- [ runner-0] o.s.boot.SpringApplication : No active profile set, falling back to default profiles: default
2017-07-21 14:37:37.659 INFO 47637 --- [ runner-0] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#3a0184b7: startup date [Fri Jul 21 14:37:37 ICT 2017]; root of context hierarchy
2017-07-21 14:37:38.831 INFO 47637 --- [ runner-0] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-07-21 14:37:38.844 INFO 47637 --- [ runner-0] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2017-07-21 14:37:38.846 INFO 47637 --- [ runner-0] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.15
2017-07-21 14:37:38.923 INFO 47637 --- [ost-startStop-1] org.apache.catalina.loader.WebappLoader : Unknown loader org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader#c0454ed class org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader
2017-07-21 14:37:38.950 INFO 47637 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-07-21 14:37:38.951 INFO 47637 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1296 ms
2017-07-21 14:37:39.020 INFO 47637 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-07-21 14:37:39.605 INFO 47637 --- [ runner-0] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-07-21 14:37:39.674 INFO 47637 --- [ runner-0] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-07-21 14:37:39.678 INFO 47637 --- [ runner-0] o.s.boot.SpringApplication : Started application in 12.556 seconds (JVM running for 14.572)
Did I do something wrong?
I just use sdkman switch back to Spring CLI v1.5.3.RELEASE and it's work.

Categories

Resources