Launching two spring boot apps at the same time using maven - java

I have two spring boot apps with their own application.properties.
One is in my src/main/resources as application.properties and the other as test.properties in src/test/resources.
I want it so that when I launch my spring boot app in main, it also simultaneously launches the spring boot app in my test. I want to do this in Maven command line but I was also wondering if it is possible to do in Spring Boot as well, perhaps programmatically?
The spring boot apps are running on localhost but two different ports.
The one in main is running on localhost:28433 and the other on localhost:9119.
I have tried running this mvn command:
mvn spring-boot:run -Drun.arguments="--server.port=9119""--server.port=28433"
I am not sure this works though.. when I run it in my terminal it outputs this:
t.TomcatWebServer : Tomcat initialized with port(s): 28433 (http)
2019-08-12 15:25:51.641 INFO 37469 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-08-12 15:25:51.641 INFO 37469 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/9.0.12
2019-08-12 15:25:51.649 INFO 37469 --- [ main] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/asluborski/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
2019-08-12 15:25:51.707 INFO 37469 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-08-12 15:25:51.707 INFO 37469 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 934 ms
2019-08-12 15:25:51.731 INFO 37469 --- [ main] o.s.b.w.servlet.ServletRegistrationBean : Servlet messageDispatcherServlet mapped to [/nulogix/ws/*]
2019-08-12 15:25:51.732 INFO 37469 --- [ main] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2019-08-12 15:25:51.735 INFO 37469 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2019-08-12 15:25:51.735 INFO 37469 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2019-08-12 15:25:51.735 INFO 37469 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'formContentFilter' to: [/*]
2019-08-12 15:25:51.736 INFO 37469 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2019-08-12 15:25:51.760 DEBUG 37469 --- [ main] c.n.b.service.PredictionEngineService : billing.engine.address=127.0.0.1
2019-08-12 15:25:51.760 DEBUG 37469 --- [ main] c.n.b.service.PredictionEngineService : billing.engine.port=9119
2019-08-12 15:25:51.760 DEBUG 37469 --- [ main] c.n.b.service.PredictionEngineService : Using http://127.0.0.1:9119
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.Injector (file:/Users/asluborski/.m2/repository/com/sun/xml/bind/jaxb-impl/2.2.11/jaxb-impl-2.2.11.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)
WARNING: Please consider reporting this to the maintainers of com.sun.xml.bind.v2.runtime.reflect.opt.Injector
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-08-12 15:25:52.037 DEBUG 37469 --- [ main] c.n.billing.ws.endpoint.AnalyzeEndPoint : billing.engine.api.version=0.97
2019-08-12 15:25:52.038 DEBUG 37469 --- [ main] c.n.billing.ws.endpoint.AnalyzeEndPoint : billing.engine.core.version=0.97
2019-08-12 15:25:52.038 DEBUG 37469 --- [ main] c.n.billing.ws.endpoint.AnalyzeEndPoint : billing.engine.core.name=Nulogix_Patient_Responsibility
2019-08-12 15:25:52.039 DEBUG 37469 --- [ main] c.n.b.ws.endpoint.GetVersionEndPoint : billing.engine.api.version=0.97
2019-08-12 15:25:52.184 INFO 37469 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-08-12 15:25:52.398 INFO 37469 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 28433 (http) with context path ''
2019-08-12 15:25:52.402 INFO 37469 --- [ main] com..billing.App : Started App in 1.995 seconds (JVM running for 9.911)
It says above that it is using 127.0.0.1:9119 but it seems to only start my main App but not my test App which is specifically called mockServerApp so I do not think it is doing what I want...
How do I launch these simultaneously?

I'm can't tell what mockServerApp is being used for, but I don't think bootRun handles multiple applications or even scans your test classes.
If you want to mock an external dependency for unit testing purposes, you should wrap the calls in a proxy class of some sort and use #MockBean to inject a mock instance.
If you want to deploy a stub external dependency for development purposes, you could create a separate project for the stub as a parent directory that would invoke maven on startup. You could even implement the mock in a different framework or language.
The most straightforward option, though would be to write a shell script that launches and kills both services.
For specifying the ports, in the application.properties of each set the server.port to be an environment variable:
primary application.conf:
server.port=${MY_APP_PORT:28433}
mock application.conf:
server.port=${MOCK_APP_PORT:9119}
For launching external dependencies in integration tests, check out Testcontainers

Related

My h2 working, but i cant connect inside of h2-console

Yoo coder, have one issue with h2-console.When i created some entitys on start,my h2 worked and i could open my h2-console and saw there tables ,but after some time i want connect again and doesn't work now.Meanwhile i added some lines and classes,but idk why doesn't work my h2-console,cause i don't touch application properties.
After lick on conect or testconect i got this error
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon Mar 14 19:12:33 CET 2022
There was an unexpected error (type=Forbidden, status=403).
My github project: https://github.com/Wynnyy/bookingdoctor-project.git
logs
2022-03-14 19:12:16.222 INFO 23108 --- [ main] s.w.b.BookingdoctorApplication : Starting BookingdoctorApplication using Java 17.0.2 on DESKTOP-K3O8I67 with PID 23108 (C:\Users\Patrik Severín\IdeaProjects\bookingdoctor\target\classes started by Wynny in C:\Users\Patrik Severín\IdeaProjects\bookingdoctor)
2022-03-14 19:12:16.224 INFO 23108 --- [ main] s.w.b.BookingdoctorApplication : No active profile set, falling back to 1 default profile: "default"
2022-03-14 19:12:16.928 INFO 23108 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-03-14 19:12:16.986 INFO 23108 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 47 ms. Found 2 JPA repository interfaces.
2022-03-14 19:12:17.670 INFO 23108 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-03-14 19:12:17.682 INFO 23108 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-03-14 19:12:17.682 INFO 23108 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.58]
2022-03-14 19:12:17.780 INFO 23108 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-03-14 19:12:17.780 INFO 23108 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1503 ms
2022-03-14 19:12:17.829 INFO 23108 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2022-03-14 19:12:18.068 INFO 23108 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2022-03-14 19:12:18.080 INFO 23108 --- [ main] o.s.b.a.h2.H2ConsoleAutoConfiguration : H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:wynny'
2022-03-14 19:12:18.277 INFO 23108 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2022-03-14 19:12:18.331 INFO 23108 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.5.Final
2022-03-14 19:12:18.497 INFO 23108 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2022-03-14 19:12:18.627 INFO 23108 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2022-03-14 19:12:19.225 INFO 23108 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2022-03-14 19:12:19.232 INFO 23108 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2022-03-14 19:12:19.540 WARN 23108 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2022-03-14 19:12:19.708 INFO 23108 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Will not secure any request
2022-03-14 19:12:20.112 INFO 23108 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2022-03-14 19:12:20.211 INFO 23108 --- [ main] s.w.b.BookingdoctorApplication : Started BookingdoctorApplication in 4.362 seconds (JVM running for 4.745)
2022-03-14 19:12:24.415 INFO 23108 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-03-14 19:12:24.415 INFO 23108 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2022-03-14 19:12:24.417 INFO 23108 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 2 ms
By default, spring-security will protect each and every end-point - So, for /error you need to manually configure like the following -
#EnableWebSecurity
public class AppSecurityConfig extends WebSecurityConfigurerAdapter {
#Override
public void configure(HttpSecurity auth) {
auth.csrf().disable()
.authorizeRequests()
.antMatchers("/error/**").permitAll() // permit-all for /error page
.anyRequest().authenticated();
}
}
For future reference:
In Spring Boot 3.0 / Spring Security 6.0 http.antMatcher() is not longer available and was replaced with http.securityMatcher().
So Subham's answer would look like that:
#Configuration
public class SecurityConfiguration {
#Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests((authz) -> authz.anyRequest().permitAll())
.csrf().disable()
.securityMatcher("/error/**")
.httpBasic(withDefaults());
return http.build();
}
}

Spring Boot 2.4.5 and Java 11 of module system question

In my example above I had spring.boot.starter.web on the classpath and the app failed to start. If I add org.apache.tomcat.embed.core then the application starts successfully.
When I configured module-info.java this way
requires spring.boot;
requires spring.boot.autoconfigure;
requires spring.web;
requires spring.boot.starter.web;
2021-05-20 10:56:09.501 INFO 17112 --- [ main] com.example.police.PoliceApplication : Starting PoliceApplication using Java 11 on zhaozhiguang-pc with PID 17112 (D:\item\police\target\classes started by zhaozhiguang in D:\item\police)
2021-05-20 10:56:09.501 INFO 17112 --- [ main] com.example.police.PoliceApplication : No active profile set, falling back to default profiles: default
2021-05-20 10:56:10.565 INFO 17112 --- [ main] com.example.police.PoliceApplication : Started PoliceApplication in 1.435 seconds (JVM running for 3.153)
Process finished with exit code 0
My guess is that Tomcat didn't boot
or
requires spring.boot;
requires spring.boot.autoconfigure;
requires spring.web;
requires org.apache.tomcat.embed.core;
This one worked
2021-05-20 10:57:48.097 INFO 13740 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2021-05-20 10:57:48.334 INFO 13740 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator'
2021-05-20 10:57:48.381 INFO 13740 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2021-05-20 10:57:48.396 INFO 13740 --- [ main] com.example.police.PoliceApplication : Started PoliceApplication in 2.001 seconds (JVM running for 3.202)
2021-05-20 10:57:48.846 INFO 13740 --- [)-192.168.1.107] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2021-05-20 10:57:48.846 INFO 13740 --- [)-192.168.1.107] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2021-05-20 10:57:48.847 INFO 13740 --- [)-192.168.1.107] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms
why?
spring.boot.starter.web depend on org.apache.tomcat.embed.core ?
One of the main features of Spring Boot is auto-configuration, which means that it configures a feature if it's available.
However, with Java modules, "available" is not just determined by the jar being on the classpath, but also by access being granted with the requires statement.
Without the requires statement, Spring Boot's auto-configuration cannot see Tomcat, so it doesn't even attempt to configure it.
Result: Silently ignores that feature.

Failed to validate data received from Authorization service - could not validate state

I downloaded ms-identity-java-webapp archive and updated the application.properties file with the Azure AD details.
When I started the Spring Boot application, I got a login page. After clicking login button, I got a microsoft login page and after logging in with the user account, I got the following log lines with an error page:
2020-09-23 16:53:06.982 INFO 708 --- [ main] c.m.a.m.MsalWebSampleApplication : Starting MsalWebSampleApplication with PID 708 (C:\Users\testuser\Downloads\ms-identity-java-webapp-master\msal-java-webapp-sample\target\classes started by testuser in C:\Users\testuser\Downloads\ms-identity-java-webapp-master\msal-java-webapp-sample)
2020-09-23 16:53:06.985 INFO 708 --- [ main] c.m.a.m.MsalWebSampleApplication : No active profile set, falling back to default profiles: default
2020-09-23 16:53:08.466 INFO 708 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-09-23 16:53:08.497 INFO 708 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-09-23 16:53:08.497 INFO 708 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.17]
2020-09-23 16:53:08.646 INFO 708 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-09-23 16:53:08.647 INFO 708 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1613 ms
2020-09-23 16:53:08.967 INFO 708 --- [ main] .s.s.UserDetailsServiceAutoConfiguration :
Using generated security password: 970ff480-0c7d-4cd0-b657-000c23a68ab4
2020-09-23 16:53:09.148 INFO 708 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#6813a331, org.springframework.security.web.context.SecurityContextPersistenceFilter#27494e46, org.springframework.security.web.header.HeaderWriterFilter#68105edc, org.springframework.security.web.csrf.CsrfFilter#6e4ea0bd, org.springframework.security.web.authentication.logout.LogoutFilter#3e598df9, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#1e411d81, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#75504cef, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#1bd81830, org.springframework.security.web.session.SessionManagementFilter#470a9030, org.springframework.security.web.access.ExceptionTranslationFilter#28782602]
2020-09-23 16:53:09.373 INFO 708 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-09-23 16:53:09.561 INFO 708 --- [ main] o.s.b.a.w.s.WelcomePageHandlerMapping : Adding welcome page template: index
2020-09-23 16:53:09.710 INFO 708 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2020-09-23 16:53:09.715 INFO 708 --- [ main] c.m.a.m.MsalWebSampleApplication : Started MsalWebSampleApplication in 3.211 seconds (JVM running for 4.717)
2020-09-23 16:53:29.556 INFO 708 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-09-23 16:53:29.556 INFO 708 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-09-23 16:53:29.562 INFO 708 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 6 ms
Failed to validate data received from Authorization service - could not validate state
Has anyone faced this issue? How can I resolve this?
This issue was already addressed on GitHub and was already fixed. Please go through the solution given here .

Suspend after `HHH000204: Processing PersistenceUnitInfo`

I'm using SpringBoot and Hibernate, but the application stops after log HHH000204: Processing PersistenceUnitInfo at start up.
What does it mean?
Full stack:
:: Spring Boot :: (v2.0.5.RELEASE)
2019-01-19 17:30:40.343 INFO 23942 --- [ main] com.mafengwo.Application : Starting Application on sunxingbindeMacBook-Pro.local with PID 23942 (/Users/sunxingbin/IdeaProjects/contentrepojob/target/classes started by sunxingbin in /Users/sunxingbin/IdeaProjects/contentrepojob)
2019-01-19 17:30:40.347 INFO 23942 --- [ main] com.mafengwo.Application : No active profile set, falling back to default profiles: default
2019-01-19 17:30:40.470 INFO 23942 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#cd3fee8: startup date [Sat Jan 19 17:30:40 CST 2019]; root of context hierarchy
2019-01-19 17:30:41.910 INFO 23942 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-01-19 17:30:42.208 INFO 23942 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$86296a04] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-01-19 17:30:42.750 INFO 23942 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 10086 (http)
2019-01-19 17:30:42.788 INFO 23942 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-01-19 17:30:42.788 INFO 23942 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.34
2019-01-19 17:30:42.801 INFO 23942 --- [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: [/Users/sunxingbin/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
2019-01-19 17:30:43.028 INFO 23942 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-01-19 17:30:43.028 INFO 23942 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2561 ms
2019-01-19 17:30:43.130 INFO 23942 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2019-01-19 17:30:43.135 INFO 23942 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2019-01-19 17:30:43.136 INFO 23942 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2019-01-19 17:30:43.136 INFO 23942 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2019-01-19 17:30:43.137 INFO 23942 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2019-01-19 17:30:43.200 INFO 23942 --- [ main] o.s.j.d.DriverManagerDataSource : Loaded JDBC driver: com.mysql.jdbc.Driver
2019-01-19 17:30:43.402 INFO 23942 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2019-01-19 17:30:43.433 INFO 23942 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2019-01-19 17:30:43.549 INFO 23942 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.2.17.Final}
2019-01-19 17:30:43.550 INFO 23942 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2019-01-19 17:30:43.599 INFO 23942 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
Sat Jan 19 17:30:43 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
2019-01-19 17:30:44.423 INFO 23942 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
Sat Jan 19 17:30:45 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
2019-01-19 17:30:45.251 INFO 23942 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-01-19 17:30:45.271 INFO 23942 --- [ main] o.s.j.d.DriverManagerDataSource : Loaded JDBC driver: com.mysql.jdbc.Driver
2019-01-19 17:30:45.276 INFO 23942 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2019-01-19 17:30:45.276 INFO 23942 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]

Spring Boot Not Deploying WAR From IntelliJ

I was trying to deploy my first Spring Boot application to WAR file but it's not working. There is no error showing but also not finding any WAR file.
I have followed all the steps found on Spring Boot documentation and all over StackOverflow. Here are these:
Step 1: I have extended SpringBootServletInitializer
#SpringBootApplication
public class SpringBoot1Application extends SpringBootServletInitializer
{
public static void main(String[] args) throws Exception
{
SpringApplication.run(SpringBoot1Application.class, args);
}
}
Step 2: Added apply plugin: 'war' and dependencies in the build.gradle file
buildscript {
ext {
springBootVersion = '2.0.3.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'
group = 'com.ranadepto'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-web')
runtime('org.springframework.boot:spring-boot-devtools')
runtime('mysql:mysql-connector-java')
testCompile('org.springframework.boot:spring-boot-starter-test')
provided 'org.springframework.boot:spring-boot-starter-tomcat'
providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
}
war {
baseName = 'SpringBoot1'
}
I am also including console output messages:
:: Spring Boot :: (v2.0.3.RELEASE)
2018-07-06 20:50:49.322 INFO 3489 --- [ restartedMain] c.r.SpringBoot1.SpringBoot1Application : Starting SpringBoot1Application on Rana-Depto-MacBook-Pro.local with PID 3489 (/Users/ranadepto/Desktop/SpringBoot1/out/production/classes started by ranadepto in /Users/ranadepto/Desktop/SpringBoot1)
2018-07-06 20:50:49.324 INFO 3489 --- [ restartedMain] c.r.SpringBoot1.SpringBoot1Application : No active profile set, falling back to default profiles: default
2018-07-06 20:50:49.375 INFO 3489 --- [ restartedMain] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#7acf6bce: startup date [Fri Jul 06 20:50:49 BDT 2018]; root of context hierarchy
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/Users/ranadepto/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/5.0.7.RELEASE/54b731178d81e66eca9623df772ff32718208137/spring-core-5.0.7.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2018-07-06 20:50:50.215 INFO 3489 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$f69149ff] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-06 20:50:50.461 INFO 3489 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2018-07-06 20:50:50.476 INFO 3489 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-07-06 20:50:50.477 INFO 3489 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.31
2018-07-06 20:50:50.480 INFO 3489 --- [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: [/Users/ranadepto/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
2018-07-06 20:50:50.527 INFO 3489 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-07-06 20:50:50.527 INFO 3489 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1157 ms
2018-07-06 20:50:50.612 INFO 3489 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-07-06 20:50:50.615 INFO 3489 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-07-06 20:50:50.615 INFO 3489 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-07-06 20:50:50.615 INFO 3489 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-07-06 20:50:50.615 INFO 3489 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-07-06 20:50:50.710 INFO 3489 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2018-07-06 20:50:50.841 INFO 3489 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2018-07-06 20:50:50.866 INFO 3489 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-07-06 20:50:50.873 INFO 3489 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2018-07-06 20:50:50.908 INFO 3489 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate Core {5.2.17.Final}
2018-07-06 20:50:50.909 INFO 3489 --- [ restartedMain] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2018-07-06 20:50:50.931 INFO 3489 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2018-07-06 20:50:50.995 INFO 3489 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
2018-07-06 20:50:51.305 INFO 3489 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-07-06 20:50:51.523 INFO 3489 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-06 20:50:51.682 INFO 3489 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#7acf6bce: startup date [Fri Jul 06 20:50:49 BDT 2018]; root of context hierarchy
2018-07-06 20:50:51.700 WARN 3489 --- [ restartedMain] 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-07-06 20:50:51.722 INFO 3489 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/reports],methods=[GET]}" onto public java.util.List<com.ranadepto.SpringBoot1.ReportModel> com.ranadepto.SpringBoot1.ReportController.getAllReports()
2018-07-06 20:50:51.723 INFO 3489 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/reports/{id}],methods=[GET]}" onto public com.ranadepto.SpringBoot1.ReportModel com.ranadepto.SpringBoot1.ReportController.getReportById(java.lang.String)
2018-07-06 20:50:51.724 INFO 3489 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/reports],methods=[POST]}" onto public com.ranadepto.SpringBoot1.ReportModel com.ranadepto.SpringBoot1.ReportController.createReport(com.ranadepto.SpringBoot1.ReportModel)
2018-07-06 20:50:51.724 INFO 3489 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/reports/{id}],methods=[PUT]}" onto public com.ranadepto.SpringBoot1.ReportModel com.ranadepto.SpringBoot1.ReportController.updateReport(java.lang.String,com.ranadepto.SpringBoot1.ReportModel)
2018-07-06 20:50:51.724 INFO 3489 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/reports/{id}],methods=[DELETE]}" onto public org.springframework.http.ResponseEntity<?> com.ranadepto.SpringBoot1.ReportController.deleteReport(java.lang.String)
2018-07-06 20:50:51.726 INFO 3489 --- [ 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-07-06 20:50:51.726 INFO 3489 --- [ 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-07-06 20:50:51.746 INFO 3489 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-06 20:50:51.746 INFO 3489 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-06 20:50:51.921 INFO 3489 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2018-07-06 20:50:51.942 INFO 3489 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-07-06 20:50:51.943 INFO 3489 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'dataSource' has been autodetected for JMX exposure
2018-07-06 20:50:51.947 INFO 3489 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource]
2018-07-06 20:50:51.972 INFO 3489 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2018-07-06 20:50:51.976 INFO 3489 --- [ restartedMain] c.r.SpringBoot1.SpringBoot1Application : Started SpringBoot1Application in 2.93 seconds (JVM running for 3.809)
And finally this is a screenshot of IntelliJ directory hierarchy:
I have been spending for hour on debugging and searching on the web and finally ended up here with a question. Please help me out with how can I get rid of this.

Categories