Spring boot - how to override the default username and password in spring security - spring

I have a spring boot application and i am trying to implement the spring security to override the default username and password generated by spring .but its not working. spring still using the default user credentials.
#EnableWebSecurity
#Configuration
public class WebSecurityConfigurtion extends WebSecurityConfigurerAdapter {
#Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("demo").password("demo").roles("USER").and().withUser("admin")
.password("admin").roles("USER", "ADMIN");
}
#Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().authenticated().and().httpBasic();
}
and this is my main spring boot class
#SpringBootApplication(exclude = { DataSourceAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class ,SecurityAutoConfiguration.class})
#EnableAsync
#EntityScan({ "com.demo.entity" })
#EnableJpaRepositories(basePackages = {"com.demo.repositories"})
#ComponentScan({ "com.demo.controller", "com.demo.service" })
#Import({SwaggerConfig.class})
public class UdeManagerServiceApplication extends SpringBootServletInitializer {
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(UdeManagerServiceApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(UdeManagerServiceApplication.class, args);
}
This is the logs, and it shows the generated password
22:26:48.537 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []
22:26:48.540 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/, /spring-boot/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter/target/classes/]
22:26:48.540 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/C:/Work/Spring/UdeManagerService/target/classes/]
2018-10-18 22:26:48.797 DEBUG 7652 --- [ restartedMain] o.s.w.c.s.StandardServletEnvironment : Adding PropertySource 'configurationProperties' with highest search precedence
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.4.RELEASE)
2018-10-18 22:26:49.218 DEBUG 7652 --- [ restartedMain] o.s.w.c.s.StandardServletEnvironment : Adding PropertySource 'servletConfigInitParams' with lowest search precedence
2018-10-18 22:26:49.219 DEBUG 7652 --- [ restartedMain] o.s.w.c.s.StandardServletEnvironment : Adding PropertySource 'servletContextInitParams' with lowest search precedence
2018-10-18 22:26:49.220 DEBUG 7652 --- [ restartedMain] o.s.w.c.s.StandardServletEnvironment : Adding PropertySource 'systemProperties' with lowest search precedence
2018-10-18 22:26:49.221 DEBUG 7652 --- [ restartedMain] o.s.w.c.s.StandardServletEnvironment : Adding PropertySource 'systemEnvironment' with lowest search precedence
2018-10-18 22:26:49.222 DEBUG 7652 --- [ restartedMain] o.s.w.c.s.StandardServletEnvironment : Initialized StandardServletEnvironment with PropertySources [StubPropertySource {name='servletConfigInitParams'}, StubPropertySource {name='servletContextInitParams'}, MapPropertySource {name='systemProperties'}, SystemEnvironmentPropertySource {name='systemEnvironment'}]
2018-10-18 22:26:49.967 INFO 7652 --- [ restartedMain] c.c.U.UdeManagerServiceApplication : Starting UdeManagerServiceApplication on TRV-LT-ANSAR with PID 7652 (C:\Work\Spring\UdeManagerService\target\classes started by Ansar.Samad in C:\Work\Spring\UdeManagerService)
2018-10-18 22:26:49.973 DEBUG 7652 --- [ restartedMain] c.c.U.UdeManagerServiceApplication : Running with Spring Boot v2.0.4.RELEASE, Spring v5.0.8.RELEASE
2018-10-18 22:26:49.976 INFO 7652 --- [ restartedMain] c.c.U.UdeManagerServiceApplication : No active profile set, falling back to default profiles: default
2018-10-18 22:26:50.614 INFO 7652 --- [ restartedMain] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#23daa694: startup date [Thu Oct 18 22:26:50 IST 2018]; root of context hierarchy
2018-10-18 22:26:53.258 DEBUG 7652 --- [ restartedMain] o.s.w.c.s.StandardServletEnvironment : Removing PropertySource 'defaultProperties'
2018-10-18 22:26:53.428 INFO 7652 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$82d409fb] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-10-18 22:26:53.936 INFO 7652 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2018-10-18 22:26:53.959 INFO 7652 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-10-18 22:26:53.960 INFO 7652 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.32
2018-10-18 22:26:53.966 INFO 7652 --- [ost-startStop-1] 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: [C:\Program Files\Java\jdk1.8.0_162\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files (x86)/Java/jre1.8.0_181/bin/client;C:/Program Files (x86)/Java/jre1.8.0_181/bin;C:/Program Files (x86)/Java/jre1.8.0_181/lib/i386;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\phython3.6\Scripts\;C:\phython3.6\;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jre1.8.0_131\bin;C:\cuia\bat;C:\apache-maven-3.5.0-bin\apache-maven-3.5.0\bin;JAVA_HOME;SPRING_HOME;C:\Program Files (x86)\Symantec\VIP Access Client\;C:\phython3.6;C:\Program Files\Git\cmd;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;TESTNG_HOME;C:\TestNg\testng-6.8.jar;C:\python-3.6.5\Scripts;C:\python-3.6.5;C:\Program Files (x86)\Yarn\bin\;C:\Program Files\nodejs\;;C:\Program Files\Microsoft VS Code\bin;C:\Users\Ansar.Samad\AppData\Local\Yarn\bin;C:\Users\Ansar.Samad\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Ansar.Samad\AppData\Roaming\npm;C:\spring-tool-suite-3.9.5.RELEASE-e4.8.0-win32\sts-bundle\sts-3.9.5.RELEASE;;.]
2018-10-18 22:26:54.081 INFO 7652 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-10-18 22:26:54.082 DEBUG 7652 --- [ost-startStop-1] o.s.web.context.ContextLoader : Published root WebApplicationContext as ServletContext attribute with name [org.springframework.web.context.WebApplicationContext.ROOT]
2018-10-18 22:26:54.082 INFO 7652 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3468 ms
2018-10-18 22:26:54.192 INFO 7652 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-10-18 22:26:54.193 INFO 7652 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-10-18 22:26:54.193 INFO 7652 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-10-18 22:26:54.193 INFO 7652 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-10-18 22:26:54.194 INFO 7652 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2018-10-18 22:26:54.194 INFO 7652 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-10-18 22:26:54.274 DEBUG 7652 --- [ restartedMain] o.s.w.c.s.StandardServletEnvironment : Replacing PropertySource 'servletContextInitParams' with 'servletContextInitParams'
2018-10-18 22:26:54.308 DEBUG 7652 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : Driver class com.mysql.jdbc.Driver found in Thread context class loader org.springframework.boot.devtools.restart.classloader.RestartClassLoader#4e843ef9
2018-10-18 22:26:54.407 DEBUG 7652 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : HikariPool-1 - configuration:
2018-10-18 22:26:54.409 DEBUG 7652 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : allowPoolSuspension.............false
2018-10-18 22:26:54.409 DEBUG 7652 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : autoCommit......................true
2018-10-18 22:26:54.409 DEBUG 7652 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : catalog.........................none
2018-10-18 22:26:54.409 DEBUG 7652 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : connectionInitSql...............none
2018-10-18 22:26:54.409 DEBUG 7652 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : connectionTestQuery.............none
2018-10-18 22:26:54.410 DEBUG 7652 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : connectionTimeout...............30000
2018-10-18 22:26:54.410 DEBUG 7652 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : dataSource......................none
2018-10-18 22:26:54.410 DEBUG 7652 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : dataSourceClassName.............none
2018-10-18 22:26:54.410 DEBUG 7652 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : dataSourceJNDI..................none
2018-10-18 22:26:54.411 DEBUG 7652 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : dataSourceProperties............{password=<masked>}
2018-10-18 22:22018-10-18 22:35:45.240 DEBUG 6720 --- [ restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping : Rejected bean name 'operationAuthReader': no URL paths identified
2018-10-18 22:35:45.240 DEBUG 6720 --- [ restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping : Rejected bean name 'operationHiddenReader': no URL paths identified
2018-10-18 22:35:45.240 DEBUG 6720 --- [ restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping : Rejected bean name 'operationHttpMethodReader': no URL paths identified
2018-10-18 22:35:45.240 DEBUG 6720 --- [ restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping : Rejected bean name 'operationImplicitParameterReader': no URL paths identified
2018-10-18 22:35:45.240 DEBUG 6720 --- [ restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping : Rejected bean name 'operationImplicitParametersReader': no URL paths identified
2018-10-18 22:35:45.240 DEBUG 6720 --- [ restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping : Rejected bean name 'operationNicknameIntoUniqueIdReader': no URL paths identified
2018-10-18 22:35:45.240 DEBUG 6720 --- [ restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping : Rejected bean name 'operationNotesReader': no URL paths identified
2018-10-18 22:35:45.256 DEBUG 6720 --- [ restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping : Rejected bean name 'systemProperties': no URL paths identified
2018-10-18 22:35:45.256 DEBUG 6720 --- [ restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping : Rejected bean name 'systemEnvironment': no URL paths identified
2018-10-18 22:35:45.256 DEBUG 6720 --- [ restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping : Rejected bean name 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry': no URL paths identified
2018-10-18 22:35:45.256 DEBUG 6720 --- [ restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping : Rejected bean name 'messageSource': no URL paths identified
2018-10-18 22:35:45.256 DEBUG 6720 --- [ restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping : Rejected bean name 'applicationEventMulticaster': no URL paths identified
2018-10-18 22:35:45.256 DEBUG 6720 --- [ restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping : Rejected bean name 'servletContext': no URL paths identified
2018-10-18 22:35:45.256 DEBUG 6720 --- [ restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping : Rejected bean name 'contextParameters': no URL paths identified
2018-10-18 22:35:45.256 DEBUG 6720 --- [ restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping : Rejected bean name 'contextAttributes': no URL paths identified
2018-10-18 22:35:45.256 INFO 6720 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-10-18 22:35:45.256 INFO 6720 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-10-18 22:35:45.271 DEBUG 6720 --- [ restartedMain] .m.m.a.ExceptionHandlerExceptionResolver : Looking for exception mappings: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#275b060b: startup date [Thu Oct 18 22:35:35 IST 2018]; root of context hierarchy
2018-10-18 22:35:45.599 INFO 6720 --- [ restartedMain] .s.s.UserDetailsServiceAutoConfiguration :
Using generated security password: e67dca07-3bc3-49e2-bc33-84c9643ef09a
2018-10-18 22:35:45.740 INFO 6720 --- [ restartedMain] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher#1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#6abf32c0, org.springframework.security.web.context.SecurityContextPersistenceFilter#b2b202e, org.springframework.security.web.header.HeaderWriterFilter#23ff67f5, org.springframework.security.web.csrf.CsrfFilter#a493c40, org.springframework.security.web.authentication.logout.LogoutFilter#776a660, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#334ce4e9, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter#1f4c6b47, org.springframework.security.web.authentication.www.BasicAuthenticationFilter#4a4c14a3, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#7793ba1a, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#4edda6d8, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#3e492163, org.springframework.security.web.session.SessionManagementFilter#68661010, org.springframework.security.web.access.ExceptionTranslationFilter#6920b121, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#35279a68]
2018-10-18 22:35:45.836 INFO 6720 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2018-10-18 22:35:45.867 INFO 6720 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-10-18 22:35:45.867 INFO 6720 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'dataSource' has been autodetected for JMX exposure
2018-10-18 22:35:45.883 INFO 6720 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource]
2018-10-18 22:35:45.883 INFO 6720 --- [ restartedMain] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 2147483647
2018-10-18 22:35:45.883 INFO 6720 --- [ restartedMain] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
2018-10-18 22:35:45.899 INFO 6720 --- [ restartedMain] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
2018-10-18 22:35:45.914 INFO 6720 --- [ restartedMain] s.d.s.w.s.ApiListingReferenceScanner : Scanning for api listing references
2018-10-18 22:35:46.086 INFO 6720 --- [ restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: testUsingPOST_1
2018-10-18 22:35:46.101 INFO 6720 --- [ restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: getDataUsingGET_1
2018-10-18 22:35:46.117 DEBUG 6720 --- [ restartedMain] o.s.w.s.resource.ResourceUrlProvider : Looking for resource handler mappings
2018-10-18 22:35:46.117 DEBUG 6720 --- [ restartedMain] o.s.w.s.resource.ResourceUrlProvider : Found resource handler mapping: URL pattern="/**/favicon.ico", locations=[class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/], ServletContext resource [/], class path resource []], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver#3914bc92]
2018-10-18 22:35:46.117 DEBUG 6720 --- [ restartedMain] o.s.w.s.resource.ResourceUrlProvider : Found resource handler mapping: URL pattern="/webjars/**", locations=[class path resource [META-INF/resources/webjars/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver#3dc6f1f0]
2018-10-18 22:35:46.117 DEBUG 6720 --- [ restartedMain] o.s.w.s.resource.ResourceUrlProvider : Found resource handler mapping: URL pattern="/**", locations=[class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/], ServletContext resource [/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver#315362d4]
2018-10-18 22:35:47.196 DEBUG 6720 --- [onnection adder] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection com.mysql.jdbc.JDBC4Connection#edd709c
2018-10-18 22:35:49.180 INFO 6720 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2018-10-18 22:35:49.180 DEBUG 6720 --- [ restartedMain] o.s.w.c.s.StandardServletEnvironment : Adding PropertySource 'server.ports' with highest search precedence
2018-10-18 22:35:49.180 INFO 6720 --- [ restartedMain] c.c.U.UdeManagerServiceApplication : Started UdeManagerServiceApplication in 14.132 seconds (JVM running for 14.884)
2018-10-18 22:35:50.929 DEBUG 6720 --- [onnection adder] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection com.mysql.jdbc.JDBC4Connection#7a5e8413

In your application.properties file add this code
spring.security.user.name = root -- this is your username
spring.security.user.password = root -- this is your password
spring.security.user.roles = user --this is your role

You need to register a UserDetailsService bean.
In this case, just expose the InMemoryUserDetailsManager as a bean in your WebSecurityConfiguration.class, like this:
// expose the UserDetailsService as a bean
#Bean
#Override
public UserDetailsService userDetailsServiceBean() throws Exception {
return super.userDetailsServiceBean();
}

This can be done using following properties on application.properties or application.yaml file.
spring.security.user.name
spring.security.user.password
spring.security.user.roles
Take a look at this.

Issue fixed by adding the config package where the security classes are availble into the component scanning of the main class.

Related

Eureka Application starts up clean but browser gets 404 (Application is not being hosted at the expected address)?

Full log of startup is below.
When I navigate to:
http://localhost:8010/eureka
there is no log output of the event so obviously the address is bad.
...
...
My URL defined in POM is
eureka.client.serviceUrl.defaultZone = http://localhost:8010/eureka
...
...
PLEASE NOTE:
I have VirtualBox and 2 virtual ethernet adapters (that haven't even caused an issue with any springboot app before, but this is my first time running Eureka)
...
...
Console log output at startup:
2019-10-18 13:35:29.693 INFO 10428 --- [ main] .p.d.PhotoAppDiscoveryServiceApplication : No active profile set, falling back to default profiles: default
2019-10-18 13:35:30.195 WARN 10428 --- [ main] o.s.boot.actuate.endpoint.EndpointId : Endpoint ID 'service-registry' contains invalid characters, please migrate to a valid format.
2019-10-18 13:35:30.356 INFO 10428 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=829b0077-09b9-383d-8219-ef5903892aeb
2019-10-18 13:35:30.415 INFO 10428 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$cee4ddf2] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-10-18 13:35:30.597 INFO 10428 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8010 (http)
2019-10-18 13:35:30.616 INFO 10428 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-10-18 13:35:30.617 INFO 10428 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.26]
2019-10-18 13:35:30.724 INFO 10428 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-10-18 13:35:30.724 INFO 10428 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1019 ms
2019-10-18 13:35:30.799 WARN 10428 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2019-10-18 13:35:30.799 INFO 10428 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2019-10-18 13:35:30.805 INFO 10428 --- [ main] c.netflix.config.DynamicPropertyFactory : DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration#166c2c17
2019-10-18 13:35:32.263 INFO 10428 --- [ main] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2019-10-18 13:35:32.470 INFO 10428 --- [ main] c.s.j.s.i.a.WebApplicationImpl : Initiating Jersey application, version 'Jersey: 1.19.1 03/11/2016 02:08 PM'
2019-10-18 13:35:32.518 INFO 10428 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2019-10-18 13:35:32.519 INFO 10428 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.thoughtworks.xstream.core.util.Fields (file:/C:/Users/user/.m2/repository/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar) to field java.util.TreeMap.comparator
WARNING: Please consider reporting this to the maintainers of com.thoughtworks.xstream.core.util.Fields
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
2019-10-18 13:35:32.606 INFO 10428 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2019-10-18 13:35:32.606 INFO 10428 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2019-10-18 13:35:32.880 WARN 10428 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2019-10-18 13:35:32.880 INFO 10428 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2019-10-18 13:35:33.005 INFO 10428 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-10-18 13:35:34.458 INFO 10428 --- [ main] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2019-10-18 13:35:34.550 INFO 10428 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2019-10-18 13:35:34.568 INFO 10428 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2019-10-18 13:35:34.568 INFO 10428 --- [ main] com.netflix.discovery.DiscoveryClient : Client configured to neither register nor query for data.
2019-10-18 13:35:34.573 INFO 10428 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1571416534572 with initial instances count: 0
2019-10-18 13:35:34.595 INFO 10428 --- [ main] c.n.eureka.DefaultEurekaServerContext : Initializing ...
2019-10-18 13:35:34.596 WARN 10428 --- [ main] c.n.eureka.cluster.PeerEurekaNodes : The replica size seems to be empty. Check the route 53 DNS Registry
2019-10-18 13:35:34.606 INFO 10428 --- [ main] c.n.e.registry.AbstractInstanceRegistry : Finished initializing remote region registries. All known remote regions: []
2019-10-18 13:35:34.607 INFO 10428 --- [ main] c.n.eureka.DefaultEurekaServerContext : Initialized
2019-10-18 13:35:34.615 INFO 10428 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator'
2019-10-18 13:35:34.669 INFO 10428 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application DISCOVERYSERVICE with eureka with status UP
2019-10-18 13:35:34.671 INFO 10428 --- [ Thread-10] o.s.c.n.e.server.EurekaServerBootstrap : Setting the eureka configuration..
2019-10-18 13:35:34.673 INFO 10428 --- [ Thread-10] o.s.c.n.e.server.EurekaServerBootstrap : Eureka data center value eureka.datacenter is not set, defaulting to default
2019-10-18 13:35:34.673 INFO 10428 --- [ Thread-10] o.s.c.n.e.server.EurekaServerBootstrap : Eureka environment value eureka.environment is not set, defaulting to test
2019-10-18 13:35:34.680 INFO 10428 --- [ Thread-10] o.s.c.n.e.server.EurekaServerBootstrap : isAws returned false
2019-10-18 13:35:34.681 INFO 10428 --- [ Thread-10] o.s.c.n.e.server.EurekaServerBootstrap : Initialized server context
2019-10-18 13:35:34.681 INFO 10428 --- [ Thread-10] c.n.e.r.PeerAwareInstanceRegistryImpl : Got 1 instances from neighboring DS node
2019-10-18 13:35:34.681 INFO 10428 --- [ Thread-10] c.n.e.r.PeerAwareInstanceRegistryImpl : Renew threshold is: 1
2019-10-18 13:35:34.681 INFO 10428 --- [ Thread-10] c.n.e.r.PeerAwareInstanceRegistryImpl : Changing status to UP
2019-10-18 13:35:34.689 INFO 10428 --- [ Thread-10] e.s.EurekaServerInitializerConfiguration : Started Eureka Server
2019-10-18 13:35:34.703 INFO 10428 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8010 (http) with context path ''
2019-10-18 13:35:34.704 INFO 10428 --- [ main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8010
2019-10-18 13:35:34.706 INFO 10428 --- [ main] .p.d.PhotoAppDiscoveryServiceApplication : Started PhotoAppDiscoveryServiceApplication in 7.989 seconds (JVM running for 8.689)
2019-10-18 13:35:36.892 INFO 10428 --- [on(1)-127.0.0.1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-10-18 13:35:36.892 INFO 10428 --- [on(1)-127.0.0.1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2019-10-18 13:35:36.903 INFO 10428 --- [on(1)-127.0.0.1] o.s.web.servlet.DispatcherServlet : Completed initialization in 11 ms
My App:
#SpringBootApplication
#EnableEurekaServer // "stands up a registry that other applications can talk to" https://spring.io/guides/gs/service-registration-and-discovery/
public class PhotoAppDiscoveryServiceApplication {
public static void main(String[] args) {
SpringApplication.run(PhotoAppDiscoveryServiceApplication.class, args);
}
}
My application.properties:
server.port=8010
spring.application.name=discoveryservice
eureka.client.registerWithEureka=false
eureka.client.fetchRegistry=false
eureka.client.serviceUrl.defaultZone = http://localhost:8010/eureka
The defaultZone http://localhost:8010 does not host the dashboard.
http://localhost:8010 hosts the dashboard.
http://localhost:8010/eureka
is the URL for Discovery Service Replicas. In this example there is only one instance of Eureka and this is it's address.
https://cloud.spring.io/spring-cloud-netflix/multi/multi__service_discovery_eureka_clients.html
please try with this. because the defaultZone should be in camel case. and server-url should with underscore.
eureka.client.service-url.defaultZone=http://localhost:8010/eureka

Cannot enable APR Protocol on Embedded Tomcat

I am trying to use the APR protocol in my Spring Boot project.
Till now i have downloaded the tomcat-native library and did what it instructed me to do, which are ./configure , make and make install. After that i copied all libtcnative files with different extensions to /usr/lib. Now Embedded Tomcat has found all tomcat-native files but it is not running tomcat using the APR protocol.
I have configured my project to run in https with a letsencrypt certificate in http/2 and I am using Ubuntu 16.04, Java 1.8.191, Spring Boot 2.0.7. Below is my logtrace when my server starts:
/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin/java -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=44947 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -javaagent:/home/samim/IntalledSoftware/idea-IU-173.4301.25/lib/idea_rt.jar=37149:/home/samim/IntalledSoftware/idea-IU-173.4301.25/bin -Dfile.encoding=UTF-8 -classpath /usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/charsets.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/cldrdata.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/icedtea-sound.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/jaccess.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/nashorn.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/sunec.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/zipfs.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/jce.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/jsse.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/management-agent.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/resources.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/rt.jar:/root/IdeaProjects/templateprocessor/target/classes:/root/.m2/repository/org/springframework/boot/spring-boot-starter-actuator/2.0.7.RELEASE/spring-boot-starter-actuator-2.0.7.RELEASE.jar:/root/.m2/repository/org/springframework/boot/spring-boot-starter/2.0.7.RELEASE/spring-boot-starter-2.0.7.RELEASE.jar:/root/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.0.7.RELEASE/spring-boot-starter-logging-2.0.7.RELEASE.jar:/root/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar:/root/.m2/repository/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:/root/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.10.0/log4j-to-slf4j-2.10.0.jar:/root/.m2/repository/org/apache/logging/log4j/log4j-api/2.10.0/log4j-api-2.10.0.jar:/root/.m2/repository/org/slf4j/jul-to-slf4j/1.7.25/jul-to-slf4j-1.7.25.jar:/root/.m2/repository/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar:/root/.m2/repository/org/yaml/snakeyaml/1.19/snakeyaml-1.19.jar:/root/.m2/repository/org/springframework/boot/spring-boot-actuator-autoconfigure/2.0.7.RELEASE/spring-boot-actuator-autoconfigure-2.0.7.RELEASE.jar:/root/.m2/repository/org/springframework/boot/spring-boot-actuator/2.0.7.RELEASE/spring-boot-actuator-2.0.7.RELEASE.jar:/root/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.9.7/jackson-databind-2.9.7.jar:/root/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.9.0/jackson-annotations-2.9.0.jar:/root/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.9.7/jackson-core-2.9.7.jar:/root/.m2/repository/org/springframework/spring-context/5.0.11.RELEASE/spring-context-5.0.11.RELEASE.jar:/root/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.9.7/jackson-datatype-jsr310-2.9.7.jar:/root/.m2/repository/io/micrometer/micrometer-core/1.0.8/micrometer-core-1.0.8.jar:/root/.m2/repository/org/hdrhistogram/HdrHistogram/2.1.10/HdrHistogram-2.1.10.jar:/root/.m2/repository/org/latencyutils/LatencyUtils/2.0.3/LatencyUtils-2.0.3.jar:/root/.m2/repository/org/springframework/boot/spring-boot-starter-security/2.0.7.RELEASE/spring-boot-starter-security-2.0.7.RELEASE.jar:/root/.m2/repository/org/springframework/spring-aop/5.0.11.RELEASE/spring-aop-5.0.11.RELEASE.jar:/root/.m2/repository/org/springframework/spring-beans/5.0.11.RELEASE/spring-beans-5.0.11.RELEASE.jar:/root/.m2/repository/org/springframework/security/spring-security-config/5.0.10.RELEASE/spring-security-config-5.0.10.RELEASE.jar:/root/.m2/repository/org/springframework/security/spring-security-web/5.0.10.RELEASE/spring-security-web-5.0.10.RELEASE.jar:/root/.m2/repository/org/springframework/spring-expression/5.0.11.RELEASE/spring-expression-5.0.11.RELEASE.jar:/root/.m2/repository/org/thymeleaf/extras/thymeleaf-extras-springsecurity4/3.0.4.RELEASE/thymeleaf-extras-springsecurity4-3.0.4.RELEASE.jar:/root/.m2/repository/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:/root/.m2/repository/org/springframework/boot/spring-boot-starter-thymeleaf/2.0.7.RELEASE/spring-boot-starter-thymeleaf-2.0.7.RELEASE.jar:/root/.m2/repository/org/thymeleaf/thymeleaf-spring5/3.0.11.RELEASE/thymeleaf-spring5-3.0.11.RELEASE.jar:/root/.m2/repository/org/thymeleaf/thymeleaf/3.0.11.RELEASE/thymeleaf-3.0.11.RELEASE.jar:/root/.m2/repository/org/attoparser/attoparser/2.0.5.RELEASE/attoparser-2.0.5.RELEASE.jar:/root/.m2/repository/org/unbescape/unbescape/1.1.6.RELEASE/unbescape-1.1.6.RELEASE.jar:/root/.m2/repository/org/thymeleaf/extras/thymeleaf-extras-java8time/3.0.2.RELEASE/thymeleaf-extras-java8time-3.0.2.RELEASE.jar:/root/.m2/repository/org/springframework/boot/spring-boot-starter-web/2.0.7.RELEASE/spring-boot-starter-web-2.0.7.RELEASE.jar:/root/.m2/repository/org/springframework/boot/spring-boot-starter-json/2.0.7.RELEASE/spring-boot-starter-json-2.0.7.RELEASE.jar:/root/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.9.7/jackson-datatype-jdk8-2.9.7.jar:/root/.m2/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.9.7/jackson-module-parameter-names-2.9.7.jar:/root/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/2.0.7.RELEASE/spring-boot-starter-tomcat-2.0.7.RELEASE.jar:/root/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.35/tomcat-embed-core-8.5.35.jar:/root/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/8.5.35/tomcat-embed-el-8.5.35.jar:/root/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/8.5.35/tomcat-embed-websocket-8.5.35.jar:/root/.m2/repository/org/hibernate/validator/hibernate-validator/6.0.13.Final/hibernate-validator-6.0.13.Final.jar:/root/.m2/repository/javax/validation/validation-api/2.0.1.Final/validation-api-2.0.1.Final.jar:/root/.m2/repository/org/jboss/logging/jboss-logging/3.3.2.Final/jboss-logging-3.3.2.Final.jar:/root/.m2/repository/com/fasterxml/classmate/1.3.4/classmate-1.3.4.jar:/root/.m2/repository/org/springframework/spring-web/5.0.11.RELEASE/spring-web-5.0.11.RELEASE.jar:/root/.m2/repository/org/springframework/spring-webmvc/5.0.11.RELEASE/spring-webmvc-5.0.11.RELEASE.jar:/root/.m2/repository/org/springframework/boot/spring-boot-devtools/2.0.7.RELEASE/spring-boot-devtools-2.0.7.RELEASE.jar:/root/.m2/repository/org/springframework/boot/spring-boot/2.0.7.RELEASE/spring-boot-2.0.7.RELEASE.jar:/root/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.0.7.RELEASE/spring-boot-autoconfigure-2.0.7.RELEASE.jar:/root/.m2/repository/org/springframework/spring-core/5.0.11.RELEASE/spring-core-5.0.11.RELEASE.jar:/root/.m2/repository/org/springframework/spring-jcl/5.0.11.RELEASE/spring-jcl-5.0.11.RELEASE.jar:/root/.m2/repository/org/springframework/security/spring-security-core/5.0.10.RELEASE/spring-security-core-5.0.10.RELEASE.jar com.siqes.TemplateprocessorApplication
19:23:01.616 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []
19:23:01.620 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/, /spring-boot/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter/target/classes/]
19:23:01.620 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/root/IdeaProjects/templateprocessor/target/classes/]
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.7.RELEASE)
2018-12-26 19:23:02.067 INFO 10929 --- [ restartedMain] com.siqes.TemplateprocessorApplication : Starting TemplateprocessorApplication on dev-76 with PID 10929 (/root/IdeaProjects/templateprocessor/target/classes started by root in /root/IdeaProjects/templateprocessor)
2018-12-26 19:23:02.069 INFO 10929 --- [ restartedMain] com.siqes.TemplateprocessorApplication : No active profile set, falling back to default profiles: default
2018-12-26 19:23:02.158 INFO 10929 --- [ restartedMain] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#2690e06e: startup date [Wed Dec 26 19:23:02 IST 2018]; root of context hierarchy
2018-12-26 19:23:04.260 INFO 10929 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 443 (https) 80 (http)
2018-12-26 19:23:04.283 INFO 10929 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-12-26 19:23:04.284 INFO 10929 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.35
2018-12-26 19:23:04.288 INFO 10929 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : Loaded APR based Apache Tomcat Native library [1.2.19] using APR version [1.5.2].
2018-12-26 19:23:04.289 INFO 10929 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2018-12-26 19:23:04.289 INFO 10929 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
2018-12-26 19:23:04.292 INFO 10929 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : OpenSSL successfully initialized [OpenSSL 1.1.1a 20 Nov 2018]
2018-12-26 19:23:04.356 INFO 10929 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-12-26 19:23:04.356 INFO 10929 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2204 ms
2018-12-26 19:23:04.975 INFO 10929 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-12-26 19:23:04.975 INFO 10929 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'webMvcMetricsFilter' to: [/*]
2018-12-26 19:23:04.976 INFO 10929 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-12-26 19:23:04.976 INFO 10929 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-12-26 19:23:04.976 INFO 10929 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-12-26 19:23:04.976 INFO 10929 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2018-12-26 19:23:04.977 INFO 10929 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpTraceFilter' to: [/*]
2018-12-26 19:23:04.977 INFO 10929 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-12-26 19:23:05.150 INFO 10929 --- [ restartedMain] .s.s.UserDetailsServiceAutoConfiguration :
Using generated security password: 7c0a25e1-aa1f-4b57-884f-94fbd8afc570
2018-12-26 19:23:05.267 INFO 10929 --- [ restartedMain] o.s.s.w.a.c.ChannelProcessingFilter : Validated configuration attributes
2018-12-26 19:23:05.290 INFO 10929 --- [ restartedMain] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher#1, [org.springframework.security.web.access.channel.ChannelProcessingFilter#c0cdb3d, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#2b320338, org.springframework.security.web.context.SecurityContextPersistenceFilter#325f68d3, org.springframework.security.web.header.HeaderWriterFilter#48e85931, org.springframework.security.web.authentication.logout.LogoutFilter#240e5c77, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#60808cc4, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#145d0cc7, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#68485018, org.springframework.security.web.session.SessionManagementFilter#d3c6627, org.springframework.security.web.access.ExceptionTranslationFilter#71d8532b, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#787589ce]
2018-12-26 19:23:05.380 INFO 10929 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-12-26 19:23:05.659 INFO 10929 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#2690e06e: startup date [Wed Dec 26 19:23:02 IST 2018]; root of context hierarchy
2018-12-26 19:23:05.710 INFO 10929 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/],methods=[GET]}" onto public java.lang.String com.siqes.templateprocessor.controller.MainController.home()
2018-12-26 19:23:05.711 INFO 10929 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/template-processor],methods=[GET]}" onto public java.lang.String com.siqes.templateprocessor.controller.MainController.templateProcessor()
2018-12-26 19:23:05.716 INFO 10929 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-12-26 19:23:05.716 INFO 10929 --- [ restartedMain] 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.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-12-26 19:23:05.741 INFO 10929 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-12-26 19:23:05.741 INFO 10929 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-12-26 19:23:06.038 INFO 10929 --- [ restartedMain] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator'
2018-12-26 19:23:06.048 INFO 10929 --- [ restartedMain] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/health],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2018-12-26 19:23:06.049 INFO 10929 --- [ restartedMain] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/info],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2018-12-26 19:23:06.051 INFO 10929 --- [ restartedMain] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto protected java.util.Map<java.lang.String, java.util.Map<java.lang.String, org.springframework.boot.actuate.endpoint.web.Link>> org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping.links(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-12-26 19:23:06.071 WARN 10929 --- [ restartedMain] on$ThymeleafSecurityDialectConfiguration : Auto-configuration for thymeleaf-extras-springsecurity4 is deprecated in favour of thymeleaf-extras-springsecurity5
2018-12-26 19:23:06.126 INFO 10929 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2018-12-26 19:23:06.168 INFO 10929 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-12-26 19:23:06.611 INFO 10929 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 443 (https) 80 (http) with context path ''
2018-12-26 19:23:06.616 INFO 10929 --- [ restartedMain] com.siqes.TemplateprocessorApplication : Started TemplateprocessorApplication in 4.983 seconds (JVM running for 5.92)
2018-12-26 19:23:07.282 INFO 10929 --- [on(4)-127.0.0.1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2018-12-26 19:23:07.282 INFO 10929 --- [on(4)-127.0.0.1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2018-12-26 19:23:07.298 INFO 10929 --- [on(4)-127.0.0.1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 16 ms
My beans are as follows:
#Configuration
public class ConnectorConfig {
#Bean
public ServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory() {
#Override
protected void postProcessContext(Context context) {
SecurityConstraint securityConstraint = new SecurityConstraint();
securityConstraint.setUserConstraint("CONFIDENTIAL");
SecurityCollection collection = new SecurityCollection();
collection.addPattern("/*");
securityConstraint.addCollection(collection);
context.addConstraint(securityConstraint);
}
};
tomcat.addAdditionalTomcatConnectors(redirectConnector());
return tomcat;
}
private Connector redirectConnector() {
Connector connector = new Connector(TomcatServletWebServerFactory.DEFAULT_PROTOCOL);
connector.setScheme("http");
connector.setPort(80);
connector.setSecure(false);
connector.setRedirectPort(443);
return connector;
}
}
I even tried using the AprLifecycleListener like below:
#Bean
public ServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory() {
#Override
protected void postProcessContext(Context context) {
SecurityConstraint securityConstraint = new SecurityConstraint();
securityConstraint.setUserConstraint("CONFIDENTIAL");
SecurityCollection collection = new SecurityCollection();
collection.addPattern("/*");
securityConstraint.addCollection(collection);
context.addConstraint(securityConstraint);
}
};
tomcat.addAdditionalTomcatConnectors(redirectConnector());
LifecycleListener aprLifecycleListener = new AprLifecycleListener();
tomcat.setProtocol("org.apache.coyote.http11.Http11AprProtocol");
tomcat.addContextLifecycleListeners(aprLifecycleListener);
return tomcat;
}
But i get error while starting tomcat with the APR:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.7.RELEASE)
2018-12-26 20:05:29.201 INFO 11939 --- [ restartedMain] com.siqes.TemplateprocessorApplication : Starting TemplateprocessorApplication on dev-76 with PID 11939 (/root/IdeaProjects/templateprocessor/target/classes started by root in /root/IdeaProjects/templateprocessor)
2018-12-26 20:05:29.203 INFO 11939 --- [ restartedMain] com.siqes.TemplateprocessorApplication : No active profile set, falling back to default profiles: default
2018-12-26 20:05:29.266 INFO 11939 --- [ restartedMain] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#57b72439: startup date [Wed Dec 26 20:05:29 IST 2018]; root of context hierarchy
2018-12-26 20:05:31.222 WARN 11939 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is java.lang.IllegalStateException: To use SSL, the connector's protocol handler must be an AbstractHttp11JsseProtocol subclass
2018-12-26 20:05:31.235 INFO 11939 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-12-26 20:05:31.244 ERROR 11939 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is java.lang.IllegalStateException: To use SSL, the connector's protocol handler must be an AbstractHttp11JsseProtocol subclass
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:157) ~[spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[spring-context-5.0.11.RELEASE.jar:5.0.11.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) [spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386) [spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1242) [spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1230) [spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at com.siqes.TemplateprocessorApplication.main(TemplateprocessorApplication.java:10) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_191]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_191]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_191]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_191]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.0.7.RELEASE.jar:2.0.7.RELEASE]
Caused by: java.lang.IllegalStateException: To use SSL, the connector's protocol handler must be an AbstractHttp11JsseProtocol subclass
at org.springframework.util.Assert.state(Assert.java:73) ~[spring-core-5.0.11.RELEASE.jar:5.0.11.RELEASE]
at org.springframework.boot.web.embedded.tomcat.SslConnectorCustomizer.customize(SslConnectorCustomizer.java:55) ~[spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.customizeSsl(TomcatServletWebServerFactory.java:317) ~[spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.customizeConnector(TomcatServletWebServerFactory.java:300) ~[spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:166) ~[spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:181) ~[spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:154) ~[spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
... 13 common frames omitted
Process finished with exit code 0
I had to remove some lines as stackoverflow has a limit of 30000 character. I am posting it in a comment. Please Help.

Spring boot: I am getting whitelabel error pae instead of view

I am writing spring boot application with spring MVC and H2 in memory database. I have a controller with mapping /posts on findAllPosts() method which returns post.jsp view. But when i run application and hit localhost:8080/posts it shows error page. In console it also shows mapping done for /posts.
Controller class-
package com.H2DatabaseDemo.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.H2DatabaseDemo.model.Post;
import com.H2DatabaseDemo.services.PostService;
#Controller
public class H2DemoController {
#Autowired
private PostService postService;
#RequestMapping("/posts")
public String findAllPost(Model model)
{
List<Post> thePosts=postService.findAllPost();
model.addAttribute("posts",thePosts);
return "posts";
}
}
Appication class-
package com.H2DatabaseDemo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
#SpringBootApplication
public class H2DatabaseDemoApplication {
public static void main(String[] args) {
SpringApplication.run(H2DatabaseDemoApplication.class, args);
}
}
property file-
spring.h2.console.enabled=true
spring.h2.console.path=/console
spring.datasource.url=jdbc:h2:mem:h2demo-app
spring.mvc.view.prefix: /WEB-INF/view/
spring.mvc.view.suffix: .jsp
stack trace-
:: Spring Boot :: (v2.0.4.RELEASE)
2018-09-16 09:19:50.379 INFO 12868 --- [ main] c.H.H2DatabaseDemoApplication : Starting H2DatabaseDemoApplication on DESKTOP-7NILS0D with PID 12868 (D:\springCourse\H2DatabaseDemo\target\classes started by Mrugesh in D:\springCourse\H2DatabaseDemo)
2018-09-16 09:19:50.384 INFO 12868 --- [ main] c.H.H2DatabaseDemoApplication : No active profile set, falling back to default profiles: default
2018-09-16 09:19:50.459 INFO 12868 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#3d299e3: startup date [Sun Sep 16 09:19:50 IST 2018]; root of context hierarchy
2018-09-16 09:19:52.000 INFO 12868 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$74090544] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-09-16 09:19:52.796 INFO 12868 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2018-09-16 09:19:52.833 INFO 12868 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-09-16 09:19:52.834 INFO 12868 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.32
2018-09-16 09:19:52.849 INFO 12868 --- [ost-startStop-1] 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: [C:\Program Files\Java\jre1.8.0_171\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre1.8.0_171/bin/server;C:/Program Files/Java/jre1.8.0_171/bin;C:/Program Files/Java/jre1.8.0_171/lib/amd64;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\nodejs\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\Microsoft VS Code\bin;C:\Users\Mrugesh\AppData\Roaming\npm;C:\Users\Mrugesh\AppData\Local\Microsoft\WindowsApps;C:\Users\Mrugesh\AppData\Local\GitHubDesktop\bin;C:\eclipse;;.]
2018-09-16 09:19:53.018 INFO 12868 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-09-16 09:19:53.018 INFO 12868 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2562 ms
2018-09-16 09:19:53.160 INFO 12868 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-09-16 09:19:53.162 INFO 12868 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet webServlet mapped to [/console/*]
2018-09-16 09:19:53.167 INFO 12868 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-09-16 09:19:53.167 INFO 12868 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-09-16 09:19:53.168 INFO 12868 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-09-16 09:19:53.168 INFO 12868 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-09-16 09:19:53.408 INFO 12868 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2018-09-16 09:19:53.806 INFO 12868 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2018-09-16 09:19:53.876 INFO 12868 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-09-16 09:19:53.905 INFO 12868 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2018-09-16 09:19:54.036 INFO 12868 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.2.17.Final}
2018-09-16 09:19:54.038 INFO 12868 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2018-09-16 09:19:54.085 INFO 12868 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2018-09-16 09:19:54.280 INFO 12868 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2018-09-16 09:19:54.962 INFO 12868 --- [ main] o.h.t.schema.internal.SchemaCreatorImpl : HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl#93824eb'
2018-09-16 09:19:54.965 INFO 12868 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-09-16 09:19:55.623 INFO 12868 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-16 09:19:55.918 INFO 12868 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#3d299e3: startup date [Sun Sep 16 09:19:50 IST 2018]; root of context hierarchy
2018-09-16 09:19:55.974 WARN 12868 --- [ main] aWebConfiguration$JpaWebMvcConfiguration : 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
2018-09-16 09:19:56.017 INFO 12868 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/posts]}" onto public java.lang.String com.H2DatabaseDemo.controller.H2DemoController.findAllPost(org.springframework.ui.Model)
2018-09-16 09:19:56.027 INFO 12868 --- [ 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.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-09-16 09:19:56.028 INFO 12868 --- [ 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.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-09-16 09:19:56.060 INFO 12868 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-16 09:19:56.060 INFO 12868 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-16 09:19:56.366 INFO 12868 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-09-16 09:19:56.370 INFO 12868 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'dataSource' has been autodetected for JMX exposure
2018-09-16 09:19:56.378 INFO 12868 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource]
2018-09-16 09:19:56.610 INFO 12868 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2018-09-16 09:19:56.614 INFO 12868 --- [ main] c.H.H2DatabaseDemoApplication : Started H2DatabaseDemoApplication in 6.721 seconds (JVM running for 7.372)
2018-09-16 09:20:06.742 INFO 12868 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2018-09-16 09:20:06.742 INFO 12868 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2018-09-16 09:20:06.884 INFO 12868 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 142 ms
2018-09-16 09:20:07.138 INFO 12868 --- [nio-8080-exec-1] o.h.h.i.QueryTranslatorFactoryInitiator : HHH000397: Using ASTQueryTranslatorFactory
Over the controller method add RequestMapping("/")
Please add these dependencies in your pom.xml
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>

Spring Boot Run failed

I am using Spring to build my application.
I used Spring Initializr to build my project.
I included the following dependencies:-
JPA
h2 (database)
ThymeLeaf templating engine
Spring Actuator
DevTools
Security
I am using IntelliJ IDEA IDE using Gradle build on Windows Machine.
NOTE:- I have not changed gradle(v4.8) build file.
Down below is the result of running SpringBootApplication:-
"C:\Program Files\Java\jdk1.8.0_171\bin\java.exe" -javaagent:C:\Users\ayman\Downloads\Software\IntelliJIdea\lib\idea_rt.jar=61199:C:\Users\E080978\Downloads\Software\IntelliJIdea\bin -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_171\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\rt.jar;C:\Users\E080978\Downloads\Mastercard Image\demo\out\production\classes;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-actuator\2.0.3.RELEASE\d370eeff676d24523ee530f6abc569474d2f9bf9\spring-boot-starter-actuator-2.0.3.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-data-jpa\2.0.3.RELEASE\56c909f49b5385793942158e143187ecc8c7b54a\spring-boot-starter-data-jpa-2.0.3.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-security\2.0.3.RELEASE\67de3ced1ebc68c7bbd9bc2ced390821fa682c2f\spring-boot-starter-security-2.0.3.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-thymeleaf\2.0.3.RELEASE\7a8cf11f5b7faa244e1979df491811bc0c858743\spring-boot-starter-thymeleaf-2.0.3.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-aop\2.0.3.RELEASE\a78c7bc25fd51b217f078421dc40d13ddc3b9f8f\spring-boot-starter-aop-2.0.3.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-jdbc\2.0.3.RELEASE\4f5f3411692a0f5efb60f7f583bdfcf49199a3d4\spring-boot-starter-jdbc-2.0.3.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter\2.0.3.RELEASE\ffaa050dbd36b0441645598f1a7ddaf67fd5e678\spring-boot-starter-2.0.3.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-devtools\2.0.3.RELEASE\478e12e423b45d182a409f12a28fb9f0cddf84bf\spring-boot-devtools-2.0.3.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-actuator-autoconfigure\2.0.3.RELEASE\f3e3392c3e8e2714fc05bbf0f3ee496ad19eedc7\spring-boot-actuator-autoconfigure-2.0.3.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\com.h2database\h2\1.4.197\bb391050048ca8ae3e32451b5a3714ecd3596a46\h2-1.4.197.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\io.micrometer\micrometer-core\1.0.5\c5eaa23f5bb1f0f4b7eb44824093874d0d9165f5\micrometer-core-1.0.5.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.hibernate\hibernate-core\5.2.17.Final\f2dc36470e7a2ffcf6106bb1625ecf5b54bb5f65\hibernate-core-5.2.17.Final.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\javax.transaction\javax.transaction-api\1.2\d81aff979d603edd90dcd8db2abc1f4ce6479e3e\javax.transaction-api-1.2.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework.data\spring-data-jpa\2.0.8.RELEASE\8b874afd15da2b4d2d9b8431ad2be0c6829e41fe\spring-data-jpa-2.0.8.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework\spring-aspects\5.0.7.RELEASE\afd3f7ecb9d7c2cb3160563f9f64b72223bb0265\spring-aspects-5.0.7.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework.security\spring-security-config\5.0.6.RELEASE\60367d94d253c82781b7f9abf2294cd0295e1c1\spring-security-config-5.0.6.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework.security\spring-security-web\5.0.6.RELEASE\f502d929ee62f5dce0fc942f5a22faa52eaaac34\spring-security-web-5.0.6.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-autoconfigure\2.0.3.RELEASE\11bc4cc96b08fabad2b3186755818fa0b32d83f\spring-boot-autoconfigure-2.0.3.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-actuator\2.0.3.RELEASE\5aa239d8ad6d8130b055caebf44467b9c55d422b\spring-boot-actuator-2.0.3.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot\2.0.3.RELEASE\b874870d915adbc3dd932e19077d3d45c8e54aa0\spring-boot-2.0.3.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework.security\spring-security-core\5.0.6.RELEASE\11c0291cc9cda839b7feb52c519f4a35dc6e251b\spring-security-core-5.0.6.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework\spring-context\5.0.7.RELEASE\243a23f8968de8754d8199d669780d683ab177bd\spring-context-5.0.7.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework\spring-aop\5.0.7.RELEASE\fdd0b6aa3c9c7a188c3bfbf6dfd8d40e843be9ef\spring-aop-5.0.7.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.thymeleaf\thymeleaf-spring5\3.0.9.RELEASE\abf84efd83808a70d982d2790f7f3a7bd3a39cf4\thymeleaf-spring5-3.0.9.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.thymeleaf.extras\thymeleaf-extras-java8time\3.0.1.RELEASE\d23760d1e53cd70c489ef40dc94ee6bd2371cceb\thymeleaf-extras-java8time-3.0.1.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-logging\2.0.3.RELEASE\7caad34f01d2688919e15e09a90467963e3d5190\spring-boot-starter-logging-2.0.3.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\javax.annotation\javax.annotation-api\1.3.2\934c04d3cfef185a8008e7bf34331b79730a9d43\javax.annotation-api-1.3.2.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework\spring-orm\5.0.7.RELEASE\4deed5f4a38d62f9dba7db8e010da8b49e322757\spring-orm-5.0.7.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework\spring-jdbc\5.0.7.RELEASE\9c78c6b9a6c603f6589b480e165939cde7bab7f9\spring-jdbc-5.0.7.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework.data\spring-data-commons\2.0.8.RELEASE\5c19af63b5acb0eab39066684e813d5ecd9d03b7\spring-data-commons-2.0.8.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework\spring-tx\5.0.7.RELEASE\4ca59b21c61162adb146ad1b40c30b60d8dc42b8\spring-tx-5.0.7.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework\spring-web\5.0.7.RELEASE\2e04c6c2922fbfa06b5948be14a5782db168b6ec\spring-web-5.0.7.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework\spring-beans\5.0.7.RELEASE\c1196cb3e56da83e3c3a02ef323699f4b05feedc\spring-beans-5.0.7.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework\spring-expression\5.0.7.RELEASE\ca01fb473f53dd0ee3c85663b26d5dc325602057\spring-expression-5.0.7.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework\spring-core\5.0.7.RELEASE\54b731178d81e66eca9623df772ff32718208137\spring-core-5.0.7.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.yaml\snakeyaml\1.19\2d998d3d674b172a588e54ab619854d073f555b5\snakeyaml-1.19.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jsr310\2.9.6\ea54f6193d224e5e5732bbd4262327eb465397c2\jackson-datatype-jsr310-2.9.6.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.9.6\cfa4f316351a91bfd95cb0644c6a2c95f52db1fc\jackson-databind-2.9.6.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.hdrhistogram\HdrHistogram\2.1.10\9e1ac84eed220281841b75e72fb9de5a297fbf04\HdrHistogram-2.1.10.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.latencyutils\LatencyUtils\2.0.3\769c0b82cb2421c8256300e907298a9410a2a3d3\LatencyUtils-2.0.3.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.aspectj\aspectjweaver\1.8.13\ad94df2a28d658a40dc27bbaff6a1ce5fbf04e9b\aspectjweaver-1.8.13.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\com.zaxxer\HikariCP\2.7.9\a83113d2c091d0d0f853dad3217bd7df3beb6ae3\HikariCP-2.7.9.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.hibernate.common\hibernate-commons-annotations\5.0.1.Final\71e1cff3fcb20d3b3af4f3363c3ddb24d33c6879\hibernate-commons-annotations-5.0.1.Final.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.jboss.logging\jboss-logging\3.3.2.Final\3789d00e859632e6c6206adc0c71625559e6e3b0\jboss-logging-3.3.2.Final.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.hibernate.javax.persistence\hibernate-jpa-2.1-api\1.0.2.Final\52afb5762c704a6b586e27742470c08f91877fc1\hibernate-jpa-2.1-api-1.0.2.Final.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.javassist\javassist\3.22.0-GA\3e83394258ae2089be7219b971ec21a8288528ad\javassist-3.22.0-GA.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\antlr\antlr\2.7.7\83cd2cd674a217ade95a4bb83a8a14f351f48bd0\antlr-2.7.7.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.jboss\jandex\2.0.3.Final\bfc4d6257dbff7a33a357f0de116be6ff951d849\jandex-2.0.3.Final.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\com.fasterxml\classmate\1.3.4\3d5f48f10bbe4eb7bd862f10c0583be2e0053c6\classmate-1.3.4.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\dom4j\dom4j\1.6.1\5d3ccc056b6f056dbf0dddfdf43894b9065a8f94\dom4j-1.6.1.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.thymeleaf\thymeleaf\3.0.9.RELEASE\64185cca50ac808ad034841c84b4013f955465d2\thymeleaf-3.0.9.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-classic\1.2.3\7c4f3c474fb2c041d8028740440937705ebb473a\logback-classic-1.2.3.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-to-slf4j\2.10.0\f7e631ccf49cfc0aefa4a2a728da7d374c05bd3c\log4j-to-slf4j-2.10.0.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.slf4j\jul-to-slf4j\1.7.25\af5364cd6679bfffb114f0dec8a157aaa283b76\jul-to-slf4j-1.7.25.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-api\1.7.25\da76ca59f6a57ee3102f8f9bd9cee742973efa8a\slf4j-api-1.7.25.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.springframework\spring-jcl\5.0.7.RELEASE\699016ddf454c2c167d9f84ae5777eccadf54728\spring-jcl-5.0.7.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.9.0\7c10d545325e3a6e72e06381afe469fd40eb701\jackson-annotations-2.9.0.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.9.6\4e393793c37c77e042ccc7be5a914ae39251b365\jackson-core-2.9.6.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.attoparser\attoparser\2.0.4.RELEASE\5cf02c4d8303a81f0c80971bb1dcd40d3ba96009\attoparser-2.0.4.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.unbescape\unbescape\1.1.5.RELEASE\46dc644ea9c234317d926ebac5bf5d8f114dc1ba\unbescape-1.1.5.RELEASE.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-core\1.2.3\864344400c3d4d92dfeb0a305dc87d953677c03c\logback-core-1.2.3.jar;C:\Users\E080978\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-api\2.10.0\fec5797a55b786184a537abd39c3fa1449d752d6\log4j-api-2.10.0.jar" com.mastercard.ayman.imagepackt.ImagePacktApplication
12:37:05.891 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []
12:37:05.898 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/, /spring-boot/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter/target/classes/]
12:37:05.898 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/C:/Users/E080978/Downloads/Mastercard%20Image/demo/out/production/classes/]
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.3.RELEASE)
2018-06-20 12:37:06.301 INFO 23152 --- [ restartedMain] c.m.a.imagepackt.ImagePacktApplication : Starting ImagePacktApplication on GH-6C9HNH2 with PID 23152 (started by E080978 in C:\Users\E080978\Downloads\Mastercard Image\demo)
2018-06-20 12:37:06.302 INFO 23152 --- [ restartedMain] c.m.a.imagepackt.ImagePacktApplication : No active profile set, falling back to default profiles: default
2018-06-20 12:37:06.374 INFO 23152 --- [ restartedMain] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#17c49070: startup date [Wed Jun 20 12:37:06 IST 2018]; root of context hierarchy
2018-06-20 12:37:07.824 INFO 23152 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$b97b663c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-06-20 12:37:08.184 INFO 23152 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2018-06-20 12:37:08.349 INFO 23152 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2018-06-20 12:37:08.409 INFO 23152 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-06-20 12:37:08.431 INFO 23152 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2018-06-20 12:37:08.523 INFO 23152 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate Core {5.2.17.Final}
2018-06-20 12:37:08.524 INFO 23152 --- [ restartedMain] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2018-06-20 12:37:08.566 INFO 23152 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2018-06-20 12:37:08.713 INFO 23152 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2018-06-20 12:37:09.315 INFO 23152 --- [ restartedMain] o.h.t.schema.internal.SchemaCreatorImpl : HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl#2c5eb52e'
2018-06-20 12:37:09.319 INFO 23152 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-06-20 12:37:10.108 WARN 23152 --- [ restartedMain] ion$DefaultTemplateResolverConfiguration : Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration)
2018-06-20 12:37:10.246 INFO 23152 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2018-06-20 12:37:10.284 INFO 23152 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-06-20 12:37:10.285 INFO 23152 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'dataSource' has been autodetected for JMX exposure
2018-06-20 12:37:10.289 INFO 23152 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource]
2018-06-20 12:37:10.302 INFO 23152 --- [ restartedMain] c.m.a.imagepackt.ImagePacktApplication : Started ImagePacktApplication in 4.384 seconds (JVM running for 5.279)
2018-06-20 12:37:10.308 INFO 23152 --- [ Thread-10] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#17c49070: startup date [Wed Jun 20 12:37:06 IST 2018]; root of context hierarchy
2018-06-20 12:37:10.312 INFO 23152 --- [ Thread-10] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2018-06-20 12:37:10.313 INFO 23152 --- [ Thread-10] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans
2018-06-20 12:37:10.314 INFO 23152 --- [ Thread-10] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2018-06-20 12:37:10.315 INFO 23152 --- [ Thread-10] .SchemaDropperImpl$DelayedDropActionImpl : HHH000477: Starting delayed drop of schema as part of SessionFactory shut-down'
2018-06-20 12:37:10.320 WARN 23152 --- [ Thread-10] o.s.b.f.support.DisposableBeanAdapter : Invocation of destroy method failed on bean with name 'inMemoryDatabaseShutdownExecutor': org.h2.jdbc.JdbcSQLException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-197]
2018-06-20 12:37:10.321 INFO 23152 --- [ Thread-10] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2018-06-20 12:37:10.323 INFO 23152 --- [ Thread-10] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
Process finished with exit code 0
According to me these two lines are the problem:
1.The first line
Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$b97b663c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-06-20 12:37:08.184 INFO 23152 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource :
2.The second line
2018-06-20 12:37:10.320 WARN 23152 --- [ Thread-10] o.s.b.f.support.DisposableBeanAdapter : Invocation of destroy method failed on bean with name 'inMemoryDatabaseShutdownExecutor': org.h2.jdbc.JdbcSQLException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-197]
I have not done any configuration on the database. Do I need to change database properties for the same?
This is expected. Your app doesn't have any web dependencies, it's simply starting up, running and closing.
Add
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
If you want an embedded container to run.
I should add you will not see this with < 2.0 and those starters, since boot 2.0 and WebFlux Spring boot starter web is no longer a transitive dependency. You must specify it.
... add ";DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" to the db URL ...
Add to application.properties file:
spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
probably you need to exclude datasource(if you already have your own datasource configured for application) auto configuration in main class.
#SpringBootApplication(exclude = { DataSourceAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class})

How to automatically initizlize the 'dispatcherServlet' the moment after the web app started in the spring boot application?

I am working on feign client with hystrix in a spring boot application. I started a eureka server and register two providers. In the feign client application I added the hystrix support. And when I request the service first time, I got the hystrix result, but after that every request could get the expected result from the provider. From the log, I see that the dispatcherServlet was lazily initialized after the first requested was made, not after the web app started. And this extends the timeout span of the hystrix. In this case, I always get the false result on the first request because of the lazy initialization of dispatcherServlet.
How could I get the first request correctly?
Is it ok to initialize
the dispatcherServet the moment after the web starts? If so,
how can I do it?
log:
:: Spring Boot :: (v1.4.0.RELEASE)
2016-10-13 15:06:03.677 INFO 41459 --- [ main] c.i.c.s.MovieFeignHystrixApplication : No active profile set, falling back to default profiles: default
2016-10-13 15:06:03.723 INFO 41459 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#2e6a5539: startup date [Thu Oct 13 15:06:03 CST 2016]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#6e509ffa
2016-10-13 15:06:05.005 INFO 41459 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'hystrixFeature' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.netflix.hystrix.HystrixCircuitBreakerConfiguration$HystrixWebConfiguration; factoryMethodName=hystrixFeature; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cloud/netflix/hystrix/HystrixCircuitBreakerConfiguration$HystrixWebConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.netflix.hystrix.HystrixCircuitBreakerConfiguration; factoryMethodName=hystrixFeature; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cloud/netflix/hystrix/HystrixCircuitBreakerConfiguration.class]]
2016-10-13 15:06:05.431 WARN 41459 --- [ main] o.s.c.a.ConfigurationClassPostProcessor : Cannot enhance #Configuration bean definition 'refreshScope' since its singleton instance has been created too early. The typical cause is a non-static #Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static'.
2016-10-13 15:06:05.705 INFO 41459 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=cc11fab8-4eec-3228-9e14-ac8a7dca16b2
2016-10-13 15:06:05.730 INFO 41459 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2016-10-13 15:06:06.367 INFO 41459 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$76aeae65] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-10-13 15:06:07.056 INFO 41459 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8022 (http)
2016-10-13 15:06:07.078 INFO 41459 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2016-10-13 15:06:07.079 INFO 41459 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.4
2016-10-13 15:06:07.266 INFO 41459 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2016-10-13 15:06:07.267 INFO 41459 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3544 ms
2016-10-13 15:06:07.883 INFO 41459 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2016-10-13 15:06:07.902 INFO 41459 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'metricFilter' to: [/*]
2016-10-13 15:06:07.903 INFO 41459 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-10-13 15:06:07.903 INFO 41459 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-10-13 15:06:07.903 INFO 41459 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-10-13 15:06:07.903 INFO 41459 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2016-10-13 15:06:07.903 INFO 41459 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'webRequestLoggingFilter' to: [/*]
2016-10-13 15:06:07.904 INFO 41459 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'applicationContextIdFilter' to: [/*]
2016-10-13 15:06:08.071 INFO 41459 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#140d1230: startup date [Thu Oct 13 15:06:08 CST 2016]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#2e6a5539
2016-10-13 15:06:08.111 INFO 41459 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2016-10-13 15:06:09.841 WARN 41459 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2016-10-13 15:06:09.842 INFO 41459 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2016-10-13 15:06:09.857 INFO 41459 --- [ main] c.netflix.config.DynamicPropertyFactory : DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration#631cb129
2016-10-13 15:06:10.026 INFO 41459 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#2e6a5539: startup date [Thu Oct 13 15:06:03 CST 2016]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#6e509ffa
2016-10-13 15:06:10.240 INFO 41459 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/feign/{id}],methods=[GET]}" onto public com.itmuch.cloud.study.user.entity.User com.itmuch.cloud.study.user.controller.FeignHystrixController.findByIdFeign(java.lang.Long)
2016-10-13 15:06:10.244 INFO 41459 --- [ 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)
2016-10-13 15:06:10.245 INFO 41459 --- [ 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)
2016-10-13 15:06:10.383 INFO 41459 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-10-13 15:06:10.383 INFO 41459 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-10-13 15:06:10.468 INFO 41459 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-10-13 15:06:11.460 INFO 41459 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/env/{name:.*}],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpoint.value(java.lang.String)
2016-10-13 15:06:11.461 INFO 41459 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/env || /env.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-10-13 15:06:11.462 INFO 41459 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/hystrix.stream/**]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.cloud.netflix.endpoint.ServletWrappingEndpoint.handle(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.lang.Exception
2016-10-13 15:06:11.464 INFO 41459 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/beans || /beans.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-10-13 15:06:11.467 INFO 41459 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/configprops || /configprops.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-10-13 15:06:11.467 INFO 41459 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/refresh || /refresh.json],methods=[POST]}" onto public java.lang.Object org.springframework.cloud.endpoint.GenericPostableMvcEndpoint.invoke()
2016-10-13 15:06:11.468 INFO 41459 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/resume || /resume.json],methods=[POST]}" onto public java.lang.Object org.springframework.cloud.endpoint.GenericPostableMvcEndpoint.invoke()
2016-10-13 15:06:11.470 INFO 41459 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/pause || /pause.json],methods=[POST]}" onto public java.lang.Object org.springframework.cloud.endpoint.GenericPostableMvcEndpoint.invoke()
2016-10-13 15:06:11.471 INFO 41459 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/autoconfig || /autoconfig.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-10-13 15:06:11.474 INFO 41459 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/heapdump || /heapdump.json],methods=[GET],produces=[application/octet-stream]}" onto public void org.springframework.boot.actuate.endpoint.mvc.HeapdumpMvcEndpoint.invoke(boolean,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.io.IOException,javax.servlet.ServletException
2016-10-13 15:06:11.475 INFO 41459 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/health || /health.json],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.invoke(java.security.Principal)
2016-10-13 15:06:11.476 INFO 41459 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/info || /info.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-10-13 15:06:11.479 INFO 41459 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/restart || /restart.json],methods=[POST]}" onto public java.lang.Object org.springframework.cloud.context.restart.RestartMvcEndpoint.invoke()
2016-10-13 15:06:11.480 INFO 41459 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/metrics/{name:.*}],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.MetricsMvcEndpoint.value(java.lang.String)
2016-10-13 15:06:11.480 INFO 41459 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/metrics || /metrics.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-10-13 15:06:11.506 INFO 41459 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/dump || /dump.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-10-13 15:06:11.529 INFO 41459 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/archaius || /archaius.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-10-13 15:06:11.562 INFO 41459 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/trace || /trace.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-10-13 15:06:11.563 INFO 41459 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/env],methods=[POST]}" onto public java.lang.Object org.springframework.cloud.context.environment.EnvironmentManagerMvcEndpoint.value(java.util.Map<java.lang.String, java.lang.String>)
2016-10-13 15:06:11.566 INFO 41459 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/env/reset],methods=[POST]}" onto public java.util.Map<java.lang.String, java.lang.Object> org.springframework.cloud.context.environment.EnvironmentManagerMvcEndpoint.reset()
2016-10-13 15:06:11.580 INFO 41459 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/features || /features.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-10-13 15:06:11.581 INFO 41459 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/mappings || /mappings.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-10-13 15:06:11.911 WARN 41459 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2016-10-13 15:06:11.911 INFO 41459 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2016-10-13 15:06:12.096 INFO 41459 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2016-10-13 15:06:12.118 INFO 41459 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'refreshScope' has been autodetected for JMX exposure
2016-10-13 15:06:12.122 INFO 41459 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'environmentManager' has been autodetected for JMX exposure
2016-10-13 15:06:12.129 INFO 41459 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'configurationPropertiesRebinder' has been autodetected for JMX exposure
2016-10-13 15:06:12.132 INFO 41459 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'refreshEndpoint' has been autodetected for JMX exposure
2016-10-13 15:06:12.134 INFO 41459 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'restartEndpoint' has been autodetected for JMX exposure
2016-10-13 15:06:12.139 INFO 41459 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'environmentManager': registering with JMX server as MBean [org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager]
2016-10-13 15:06:12.373 INFO 41459 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'restartEndpoint': registering with JMX server as MBean [org.springframework.cloud.context.restart:name=restartEndpoint,type=RestartEndpoint]
2016-10-13 15:06:12.394 INFO 41459 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'refreshScope': registering with JMX server as MBean [org.springframework.cloud.context.scope.refresh:name=refreshScope,type=RefreshScope]
2016-10-13 15:06:12.412 INFO 41459 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'configurationPropertiesRebinder': registering with JMX server as MBean [org.springframework.cloud.context.properties:name=configurationPropertiesRebinder,context=2e6a5539,type=ConfigurationPropertiesRebinder]
2016-10-13 15:06:12.427 INFO 41459 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'refreshEndpoint': registering with JMX server as MBean [org.springframework.cloud.endpoint:name=refreshEndpoint,type=RefreshEndpoint]
2016-10-13 15:06:12.720 INFO 41459 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0
2016-10-13 15:06:12.741 INFO 41459 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2016-10-13 15:06:13.225 INFO 41459 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2016-10-13 15:06:13.228 INFO 41459 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2016-10-13 15:06:13.462 INFO 41459 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2016-10-13 15:06:13.462 INFO 41459 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2016-10-13 15:06:13.838 INFO 41459 --- [ main] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2016-10-13 15:06:13.892 INFO 41459 --- [ main] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2016-10-13 15:06:13.892 INFO 41459 --- [ main] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2016-10-13 15:06:13.892 INFO 41459 --- [ main] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2016-10-13 15:06:13.892 INFO 41459 --- [ main] com.netflix.discovery.DiscoveryClient : Application is null : false
2016-10-13 15:06:13.892 INFO 41459 --- [ main] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2016-10-13 15:06:13.893 INFO 41459 --- [ main] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2016-10-13 15:06:13.893 INFO 41459 --- [ main] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2016-10-13 15:06:14.350 INFO 41459 --- [ main] com.netflix.discovery.DiscoveryClient : The response status is 200
2016-10-13 15:06:14.353 INFO 41459 --- [ main] com.netflix.discovery.DiscoveryClient : Starting heartbeat executor: renew interval is: 30
2016-10-13 15:06:14.356 INFO 41459 --- [ main] c.n.discovery.InstanceInfoReplicator : InstanceInfoReplicator onDemand update allowed rate per min is 4
2016-10-13 15:06:14.362 INFO 41459 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1476342374362 with initial instances count: 3
2016-10-13 15:06:14.477 INFO 41459 --- [ main] c.n.e.EurekaDiscoveryClientConfiguration : Registering application microservice-consumer-movie-feign-with-hystrix-stream with eureka with status UP
2016-10-13 15:06:14.478 INFO 41459 --- [ main] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1476342374477, current=UP, previous=STARTING]
2016-10-13 15:06:14.479 INFO 41459 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_MICROSERVICE-CONSUMER-MOVIE-FEIGN-WITH-HYSTRIX-STREAM/10.106.192.57:microservice-consumer-movie-feign-with-hystrix-stream:8022: registering service...
2016-10-13 15:06:14.542 INFO 41459 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_MICROSERVICE-CONSUMER-MOVIE-FEIGN-WITH-HYSTRIX-STREAM/10.106.192.57:microservice-consumer-movie-feign-with-hystrix-stream:8022 - registration status: 204
2016-10-13 15:06:14.548 INFO 41459 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 2147483647
2016-10-13 15:06:14.555 INFO 41459 --- [ main] ration$HystrixMetricsPollerConfiguration : Starting poller
2016-10-13 15:06:14.661 INFO 41459 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8022 (http)
2016-10-13 15:06:14.662 INFO 41459 --- [ main] c.n.e.EurekaDiscoveryClientConfiguration : Updating port to 8022
2016-10-13 15:06:14.668 INFO 41459 --- [ main] c.i.c.s.MovieFeignHystrixApplication : Started MovieFeignHystrixApplication in 14.338 seconds (JVM running for 15.302)
2016-10-13 15:06:59.127 INFO 41459 --- [nio-8022-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2016-10-13 15:06:59.128 INFO 41459 --- [nio-8022-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2016-10-13 15:06:59.202 INFO 41459 --- [nio-8022-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 74 ms
2016-10-13 15:07:00.304 INFO 41459 --- [provider-user-1] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#353c426d: startup date [Thu Oct 13 15:07:00 CST 2016]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#2e6a5539
2016-10-13 15:07:00.407 INFO 41459 --- [provider-user-1] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2016-10-13 15:07:00.827 INFO 41459 --- [provider-user-1] c.netflix.config.ChainedDynamicProperty : Flipping property: microservice-provider-user.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
2016-10-13 15:07:00.882 INFO 41459 --- [provider-user-1] c.n.u.concurrent.ShutdownEnabledTimer : Shutdown hook installed for: NFLoadBalancer-PingTimer-microservice-provider-user
2016-10-13 15:07:00.944 INFO 41459 --- [provider-user-1] c.netflix.loadbalancer.BaseLoadBalancer : Client:microservice-provider-user instantiated a LoadBalancer:DynamicServerListLoadBalancer:{NFLoadBalancer:name=microservice-provider-user,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:null
2016-10-13 15:07:00.953 INFO 41459 --- [provider-user-1] c.n.l.DynamicServerListLoadBalancer : Using serverListUpdater PollingServerListUpdater
2016-10-13 15:07:00.993 INFO 41459 --- [provider-user-1] c.netflix.config.ChainedDynamicProperty : Flipping property: microservice-provider-user.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
2016-10-13 15:07:00.996 INFO 41459 --- [provider-user-1] c.n.l.DynamicServerListLoadBalancer : DynamicServerListLoadBalancer for client microservice-provider-user initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=microservice-provider-user,current list of Servers=[10.106.192.57:8001, 10.106.192.57:8000],Load balancer stats=Zone stats: {defaultzone=[Zone:defaultzone; Instance count:2; Active connections count: 0; Circuit breaker tripped count: 0; Active connections per server: 0.0;]
},Server stats: [[Server:10.106.192.57:8001; Zone:defaultZone; Total Requests:0; Successive connection failure:0; Total blackout seconds:0; Last connection made:Thu Jan 01 08:00:00 CST 1970; First connection made: Thu Jan 01 08:00:00 CST 1970; Active Connections:0; total failure count in last (1000) msecs:0; average resp time:0.0; 90 percentile resp time:0.0; 95 percentile resp time:0.0; min resp time:0.0; max resp time:0.0; stddev resp time:0.0]
, [Server:10.106.192.57:8000; Zone:defaultZone; Total Requests:0; Successive connection failure:0; Total blackout seconds:0; Last connection made:Thu Jan 01 08:00:00 CST 1970; First connection made: Thu Jan 01 08:00:00 CST 1970; Active Connections:0; total failure count in last (1000) msecs:0; average resp time:0.0; 90 percentile resp time:0.0; 95 percentile resp time:0.0; min resp time:0.0; max resp time:0.0; stddev resp time:0.0]
]}ServerList:org.springframework.cloud.netflix.ribbon.eureka.DomainExtractingServerList#14ee3ae0
2016-10-13 15:07:01.302 INFO 41459 --- [ HystrixTimer-1] FeignHystrixClient$HystrixClientFallback : 异常发生,进入fallback方法,接收的参数:id = 4
2009########
2016-10-13 15:07:01.959 INFO 41459 --- [erListUpdater-0] c.netflix.config.ChainedDynamicProperty : Flipping property: microservice-provider-user.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
Thanks.
I add this config hystrix.command.default.execution.timeout.enabled=false
in the application.yml, and it worked. And there is a similar solution here.Initial Request with Feign, Ribbon, Hystrix, and Consul Fails
Another solution is add config: spring.mvc.servlet.load-on-startup: 1. But this time, it still could turn on the hystrix rule to return false result.

Resources