Run different profiles on Spring - spring

I have an application where I need to run 3 profiles (united-states, france and vietnam) as shown in application.yml file shown below. These 3 profiles should come under registered service in my Eureka server that is running on port 9000.
I have run java -jar -Dspring.profiles.active=united-states xxx.jar to run my Spring application, but my Spring application defaults to port 8761 and my service is not registered in Eureka server.
---
# This default profile is used when running a single instance completely standalone:
spring:
profiles: default
server:
port: 9000
eureka:
instance:
hostname: my-eureka-server.com
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
# united-states, france, and vietnam illustrate running 3 intercommunicating instances.
# This example has them running side-by-side on localhost
# -- which is unrealistic in production
# -- but does illustrate how multiple instances collaborate.
#
# Run by opening 3 separate command prompts:
# java -jar -Dspring.profiles.active=united-states SpringCloudServiceRegistrationEurekaServer.jar
# java -jar -Dspring.profiles.active=france SpringCloudServiceRegistrationEurekaServer.jar
# java -jar -Dspring.profiles.active=vietnam SpringCloudServiceRegistrationEurekaServer.jar
---
spring:
profiles: united-states
application:
name: eureka-server-clustered # ==> This is Service-Id
server:
port: 9001
eureka:
instance:
hostname: my-eureka-server-us.com
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://my-eureka-server-fr.com:9002/eureka/,http://my-eureka-server-vn.com:9003/eureka/
---
spring:
profiles: france
application:
name: eureka-server-clustered # ==> This is Service-Id
server:
port: 9002
eureka:
instance:
hostname: my-eureka-server-fr.com
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://my-eureka-server-us.com:9001/eureka/,http://my-eureka-server-vn.com:9003/eureka/
---
spring:
profiles: vietnam
application:
name: eureka-server-clustered # ==> This is Service-Id
server:
port: 9003
eureka:
instance:
hostname: my-eureka-server-vn.com
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://my-eureka-server-us.com:9001/eureka/,http://my-eureka-server-fr.com:9002/eureka/
Log:
2019-04-16 06:41:10.681 INFO 31061 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$75804a9c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.4.RELEASE)
2019-04-16 06:41:11.142 INFO 31061 --- [ main] rviceRegistrationEurekaServerApplication : The following profiles are active: united-states
2019-04-16 06:41:12.264 INFO 31061 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-04-16 06:41:12.284 INFO 31061 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 11ms. Found 0 repository interfaces.
2019-04-16 06:41:12.477 WARN 31061 --- [ main] o.s.boot.actuate.endpoint.EndpointId : Endpoint ID 'service-registry' contains invalid characters, please migrate to a valid format.
2019-04-16 06:41:12.825 INFO 31061 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=aedccd61-e8da-3db8-953a-28c197e2743c
2019-04-16 06:41:13.026 INFO 31061 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$5966479f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-04-16 06:41:13.076 INFO 31061 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$75804a9c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-04-16 06:41:13.530 INFO 31061 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8761 (http)
2019-04-16 06:41:13.573 INFO 31061 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-04-16 06:41:13.574 INFO 31061 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.17]
2019-04-16 06:41:13.690 INFO 31061 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-04-16 06:41:13.690 INFO 31061 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2525 ms
2019-04-16 06:41:13.887 WARN 31061 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2019-04-16 06:41:14.683 INFO 31061 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2019-04-16 06:41:15.126 INFO 31061 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2019-04-16 06:41:15.230 INFO 31061 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2019-04-16 06:41:15.316 INFO 31061 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.3.9.Final}
2019-04-16 06:41:15.320 INFO 31061 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2019-04-16 06:41:15.484 INFO 31061 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
2019-04-16 06:41:15.769 INFO 31061 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2019-04-16 06:41:16.039 INFO 31061 --- [ main] o.h.t.schema.internal.SchemaCreatorImpl : HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl#6c841199'
2019-04-16 06:41:16.043 INFO 31061 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-04-16 06:41:16.068 WARN 31061 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2019-04-16 06:41:16.362 INFO 31061 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-04-16 06:41:16.436 WARN 31061 --- [ 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
2019-04-16 06:41:17.084 INFO 31061 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator'
2019-04-16 06:41:17.226 INFO 31061 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2019-04-16 06:41:17.290 INFO 31061 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application EUREKA-SERVER with eureka with status UP
2019-04-16 06:41:17.353 INFO 31061 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8761 (http) with context path ''
2019-04-16 06:41:17.354 INFO 31061 --- [ main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8761
2019-04-16 06:41:17.360 INFO 31061 --- [ main] rviceRegistrationEurekaServerApplication : Started SpringCloudServiceRegistrationEurekaServerApplication in 7.941 seconds (JVM running for 8.624)
Note: I am using Intellij on Ubuntu and had configured my /etc/hosts file to include these hosts:
127.0.0.1 my-eureka-server.com
127.0.0.1 my-eureka-server-us.com
127.0.0.1 my-eureka-server-fr.com
127.0.0.1 my-eureka-server-vn.com

Your app is running as Eureka Server. If that's not what you expect, disable #EnableEurekaServer annotation if you have it on your #SpringBootApplication annotated class

Related

Spring Eureka Client won't connect server

I am making an application with multiple Eureka servers connecting to one Eureka Server. Currently I have two services. The server runs on port 8761, service one runs on 8081 and service two runs on 8082. My first service does connect successfully to the server, however my second service doesn't connect to the server and doesn't give any error messages in the console.
This is from my second service that won't connect:
spring:
application:
name: stock-service
datasource:
url: jdbc:postgresql://localhost:5433/thuusbezorgd
username: postgres
password: secretpassword
driver-class-name: org.postgresql.Driver
jpa:
database-platform: org.hibernate.dialect.PostgresSQLDialect
show-sql: true
jpa:
generate-ddl: true
defer-datasource-initialization: true
hibernate:
ddl-auto: create-drop
sql:
init:
mode: always
server:
port: 8082
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
#SpringBootApplication
#EnableEurekaClient
public class StockServiceApplication {
public static void main(String[] args) {
SpringApplication.run(StockServiceApplication.class, args);
}
}
This is the application.yml from the working service that does connect:
spring:
application:
name: shopping-cart-service
server:
port: 8081
shopping-cart:
redis:
host: localhost
port: 6379
password: ''
memcached:
host: localhost
port: 11211
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/
I am getting 0 error messages in my console from Eureka, this is the output of the first service that isn't connecting to the server:
2022-11-29T20:55:10.956+01:00 INFO 8344 --- [ main] c.j.s.StockServiceApplication : Starting StockServiceApplication using Java 18.0.2 with PID 8344 (D:\school\thuusbezorgd-JaimieVos\stock-service\target\classes started by jaimi in D:\school\thuusbezorgd-JaimieVos\stock-service)
2022-11-29T20:55:10.959+01:00 INFO 8344 --- [ main] c.j.s.StockServiceApplication : No active profile set, falling back to 1 default profile: "default"
2022-11-29T20:55:11.424+01:00 INFO 8344 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-11-29T20:55:11.542+01:00 INFO 8344 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 112 ms. Found 2 JPA repository interfaces.
2022-11-29T20:55:11.907+01:00 INFO 8344 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8082 (http)
2022-11-29T20:55:11.920+01:00 INFO 8344 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-11-29T20:55:11.920+01:00 INFO 8344 --- [ main] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.1]
2022-11-29T20:55:12.000+01:00 INFO 8344 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-11-29T20:55:12.000+01:00 INFO 8344 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1004 ms
2022-11-29T20:55:12.105+01:00 INFO 8344 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2022-11-29T20:55:12.141+01:00 INFO 8344 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 6.1.5.Final
2022-11-29T20:55:12.260+01:00 WARN 8344 --- [ main] org.hibernate.orm.deprecation : HHH90000021: Encountered deprecated setting [javax.persistence.sharedCache.mode], use [jakarta.persistence.sharedCache.mode] instead
2022-11-29T20:55:12.360+01:00 INFO 8344 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2022-11-29T20:55:12.478+01:00 INFO 8344 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection#1f172892
2022-11-29T20:55:12.479+01:00 INFO 8344 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2022-11-29T20:55:12.514+01:00 INFO 8344 --- [ main] SQL dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2022-11-29T20:55:13.172+01:00 WARN 8344 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Warning Code: 0, SQLState: 00000
2022-11-29T20:55:13.173+01:00 WARN 8344 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : relation "product_ingredient" does not exist, skipping
2022-11-29T20:55:13.174+01:00 WARN 8344 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Warning Code: 0, SQLState: 00000
2022-11-29T20:55:13.175+01:00 WARN 8344 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : relation "product_ingredient" does not exist, skipping
2022-11-29T20:55:13.176+01:00 WARN 8344 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Warning Code: 0, SQLState: 00000
2022-11-29T20:55:13.176+01:00 WARN 8344 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : table "ingredient" does not exist, skipping
2022-11-29T20:55:13.177+01:00 WARN 8344 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Warning Code: 0, SQLState: 00000
2022-11-29T20:55:13.178+01:00 WARN 8344 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : table "product" does not exist, skipping
2022-11-29T20:55:13.179+01:00 WARN 8344 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Warning Code: 0, SQLState: 00000
2022-11-29T20:55:13.179+01:00 WARN 8344 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : table "product_ingredient" does not exist, skipping
2022-11-29T20:55:13.222+01:00 INFO 8344 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2022-11-29T20:55:13.228+01:00 INFO 8344 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2022-11-29T20:55:13.445+01:00 WARN 8344 --- [ 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-11-29T20:55:13.818+01:00 INFO 8344 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8082 (http) with context path ''
2022-11-29T20:55:13.826+01:00 INFO 8344 --- [ main] c.j.s.StockServiceApplication : Started StockServiceApplication in 3.279 seconds (process running for 3.777)
So I am wondering if there is something I am completely missing because I cannot find anything that would cause service 1 not to work but service 2 running absolutely fine. When I visit my first service that doesn't connect to the server from its url itself through localhost:8082 it works fine.
I tried switching the ports but service 1 didn't want to connect with any port.

How to reduce the spring startup time

We are trying to deploy our spring boot application into AWS Lamda. While triggering an API through API gateway it is taking more time(28 to 30sec) to start up so I am getting timeout error as a response. And we configured Lamda memory as 512 MB.
Tried with the below changes as well:
Removed Unused dependencies from pom file.
Made static configuration for database connection.
Configured spring.jpa.hibernate.ddl-auto as none for avoiding the database initialization.
With spring.main.lazy-initialization=true
By #EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
Any suggestions would be welcome.
Adding logs:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot ::
2021-09-27 09:08:38.938 INFO 1 --- [ main] lambdainternal.LambdaRTEntry : Starting LambdaRTEntry using Java 1.8.0_302 on 169.254.30.181 with PID 1 (/var/runtime/lib/LambdaJavaRTEntry-1.0.jar started by sbx_user1051 in /)
2021-09-27 09:08:38.941 INFO 1 --- [ main] lambdainternal.LambdaRTEntry : No active profile set, falling back to default profiles: default
2021-09-27 09:08:43.719 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-09-27 09:08:44.748 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 983 ms. Found 20 JPA repository interfaces.
2021-09-27 09:08:47.871 INFO 1 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-09-27 09:08:48.085 INFO 1 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version [WORKING]
2021-09-27 09:08:48.906 INFO 1 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-09-27 09:08:49.322 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-09-27 09:08:50.697 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-09-27 09:08:50.779 INFO 1 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2021-09-27 09:08:57.684 INFO 1 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-09-27 09:08:57.759 INFO 1 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-09-27 09:09:07.124 INFO 1 --- [ main] lambdainternal.LambdaRTEntry : Started LambdaRTEntry in 30.106 seconds (JVM running for 31.393)
2021-09-27 09:09:07.188 INFO 1 --- [ main] c.f.c.c.BeanFactoryAwareFunctionRegistry : Looking up function 'function' with acceptedOutputTypes: []
2021-09-27 09:09:07.190 WARN 1 --- [ main] c.f.c.c.BeanFactoryAwareFunctionRegistry : !!! Failed to discover function 'function' in function catalog. Function available in catalog are: [lamdaFunction, functionRouter]
2021-09-27 09:09:07.190 INFO 1 --- [ main] c.f.c.c.BeanFactoryAwareFunctionRegistry : Looking up function 'consumer' with acceptedOutputTypes: []
2021-09-27 09:09:07.190 WARN 1 --- [ main] c.f.c.c.BeanFactoryAwareFunctionRegistry : !!! Failed to discover function 'consumer' in function catalog. Function available in catalog are: [lamdaFunction, functionRouter]
2021-09-27 09:09:07.191 INFO 1 --- [ main] c.f.c.c.BeanFactoryAwareFunctionRegistry : Looking up function 'supplier' with acceptedOutputTypes: []
2021-09-27 09:09:07.191 WARN 1 --- [ main] c.f.c.c.BeanFactoryAwareFunctionRegistry : !!! Failed to discover function 'supplier' in function catalog. Function available in catalog are: [lamdaFunction, functionRouter]
2021-09-27 09:09:07.192 INFO 1 --- [ main] c.f.c.c.BeanFactoryAwareFunctionRegistry : Looking up function 'lamdaFunction' with acceptedOutputTypes: []
Based on my experience in general the warm up time is longer for Spring Boot services but if you have more requests coming in a short period, from the second call it should be faster.
If your client can wait a little bit more than 30 seconds, then you can increase the timeout for the Lambda function itself: Lambda/Function/General Configuration/Timeout.
Be careful with connecting to a DB from Lambda, because as Lambda scales out, you may run out of DB connections: https://solidstudio.io/blog/aws-handle-database-connection
For first time startup, generally Spring Boot with Hibernate does not go well with quick startup environments like Lambdas. There are few techniques which can be tried as mentioned here or an alternate solution like Quarkus is better fit. Many people have also gone the route of perpetually warming up the lambdas by pinging.
Your connection-pool (HikariCP) setup is quite fast so it does not look like database connection issue
2021-09-27 09:08:49.322 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-09-27 09:08:50.697 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
Most of your time seems to be spending on loading Spring classes and setup (approx 5s)
2021-09-27 09:08:38.941 INFO 1 --- [ main] lambdainternal.LambdaRTEntry : No active profile set, falling back to default profiles: default
2021-09-27 09:08:43.719 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT
And also Hibernate setup ( which scans the entities, creates auto-generated queries etc.) - approx 10s
2021-09-27 09:08:47.871 INFO 1 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] 2021-09-27 09:08:48.085 INFO 1 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version [WORKING] 2021-09-27 09:08:48.906 INFO 1 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-09-27 09:08:49.322 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-09-27 09:08:50.697 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-09-27 09:08:50.779 INFO 1 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect 2021-09-27 09:08:57.684 INFO 1 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-09-27 09:08:57.759 INFO 1 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
Hope you are not using schema auto-update feature of hibernate because then it spends some time there as well.

Spring Cloud Vault with Spring Boot 2.4+ config not working as expected

I have a Spring Boot project that gets properties and passwords from vault. In Spring Boot 2.4 and later, the team has decided to change way to load config files. Now we need to use Spring Config Data to load this.
After reading through docs and examples I setup sample project. Here I am defining vault details on application.yml by following official example. And defined environment specific files in dev.yml and prod.yml, which contain environment specific properties and files.
Github Example
application.yml
server:
port: 8081
spring:
application:
name: pres
cloud:
vault:
authentication: TOKEN
uri: ${VAULT_URL}
connection-timeout: 5000
read-timeout: 15000
kv:
enabled: true
backend: secret
application-name: app/pres
token: ${TOKEN}
config:
import: vault://secret/app/pres
---
spring:
config:
activate:
on-profile: "dev"
import: dev.yml
---
spring:
config:
activate:
on-profile: "prod"
import: prod.yml
dev.yml
spring:
datasource:
url: "jdbc:mysql://localhost/dev"
username: "dev"
password: "dev"
#### ELK Logging
elk:
logging:
rabbitmq:
hostname: ${pres.elk.logging.rabbitmq.hostname}
port: 5672
username: ${pres.elk.logging.rabbitmq.username}
password: ${pres.elk.logging.rabbitmq.password}
projectVersion: '#project.version#'
prod.yml
spring:
datasource:
url: "jdbc:mysql://localhost:3306/prod"
username: "prod"
password: "prod"
#### ELK Logging
elk:
logging:
rabbitmq:
hostname: ${pres.elk.logging.rabbitmq.hostname}
port: 5672
username: ${pres.elk.logging.rabbitmq.username}
password: ${pres.elk.logging.rabbitmq.password}
projectVersion: '#project.version#'
So when I start the application, Spring Boot supposed to replace placeholders with actual values from vault. However I just see place holders as below
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.5.2)
2021-06-26 12:14:03.546 INFO 69016 --- [ restartedMain] c.e.profiletest.ProfileTestApplication : Starting ProfileTestApplication using Java 16.0.1 on pjmacbookpro with PID 69016 (/Users/pjadda/IdeaProjects/ProfileTest/target/classes started by pjadda in /Users/pjadda/IdeaProjects/ProfileTest)
2021-06-26 12:14:03.548 INFO 69016 --- [ restartedMain] c.e.profiletest.ProfileTestApplication : The following profiles are active: dev
2021-06-26 12:14:03.593 INFO 69016 --- [ restartedMain] o.s.v.c.e.LeaseAwareVaultPropertySource : Vault location [secret/app/pres] not resolvable: Not found
2021-06-26 12:14:03.594 INFO 69016 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2021-06-26 12:14:03.594 INFO 69016 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2021-06-26 12:14:04.176 INFO 69016 --- [ restartedMain] o.s.cloud.context.scope.GenericScope : BeanFactory id=6bdb5f01-aa31-3158-8281-edfa1a02ac83
2021-06-26 12:14:04.603 INFO 69016 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8081 (http)
2021-06-26 12:14:04.615 INFO 69016 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-06-26 12:14:04.615 INFO 69016 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.48]
2021-06-26 12:14:04.680 INFO 69016 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-06-26 12:14:04.680 INFO 69016 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1085 ms
2021-06-26 12:14:05.032 INFO 69016 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2021-06-26 12:14:05.121 INFO 69016 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8081 (http) with context path ''
2021-06-26 12:14:05.135 INFO 69016 --- [ restartedMain] c.e.profiletest.ProfileTestApplication : Started ProfileTestApplication in 2.79 seconds (JVM running for 3.622)
2021-06-26 12:14:05.465 INFO 69016 --- [nio-8081-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2021-06-26 12:14:05.465 INFO 69016 --- [nio-8081-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2021-06-26 12:14:05.466 INFO 69016 --- [nio-8081-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms
username:${pres.elk.logging.rabbitmq.username}
password:${pres.elk.logging.rabbitmq.password}

status:401 unauthorized in postman

Iam working in springboot application and iam trying to save the data in database, code is executing properly and not getting any error during execution but when iam trying to post the url in postman iam getting status: 401 unauthorized
any quick suggestion
console
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.4.RELEASE)
2020-12-08 17:34:07.094 INFO 7236 --- [ main] c.regestration.RegestrationApplication : Starting RegestrationApplication on Darshan with PID 7236 (C:\Users\admin\Desktop\regestration\target\classes started by admin in C:\Users\admin\Desktop\regestration)
2020-12-08 17:34:07.111 INFO 7236 --- [ main] c.regestration.RegestrationApplication : No active profile set, falling back to default profiles: default
2020-12-08 17:34:08.584 INFO 7236 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
2020-12-08 17:34:08.803 INFO 7236 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 202ms. Found 1 JPA repository interfaces.
2020-12-08 17:34:10.751 INFO 7236 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8085 (http)
2020-12-08 17:34:10.788 INFO 7236 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-12-08 17:34:10.788 INFO 7236 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.38]
2020-12-08 17:34:11.158 INFO 7236 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-12-08 17:34:11.158 INFO 7236 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3827 ms
2020-12-08 17:34:11.617 INFO 7236 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-12-08 17:34:11.815 INFO 7236 --- [ task-1] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-12-08 17:34:11.935 WARN 7236 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-12-08 17:34:12.006 INFO 7236 --- [ task-1] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.21.Final
2020-12-08 17:34:13.075 INFO 7236 --- [ task-1] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-12-08 17:34:13.554 INFO 7236 --- [ task-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-12-08 17:34:14.050 INFO 7236 --- [ main] .s.s.UserDetailsServiceAutoConfiguration :
Using generated security password: 7406d0eb-72dc-4ce4-a8cc-220d3c523098
2020-12-08 17:34:14.273 INFO 7236 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#574cd322, org.springframework.security.web.context.SecurityContextPersistenceFilter#55e2fe3c, org.springframework.security.web.header.HeaderWriterFilter#64f1fd08, org.springframework.security.web.csrf.CsrfFilter#7187bac9, org.springframework.security.web.authentication.logout.LogoutFilter#5c8e67b9, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#1174a305, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter#43e1692f, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter#45c2e0a6, org.springframework.security.web.authentication.www.BasicAuthenticationFilter#1f3165e7, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#12c60152, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#692e028d, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#119c745c, org.springframework.security.web.session.SessionManagementFilter#282ffbf5, org.springframework.security.web.access.ExceptionTranslationFilter#6c15e8c7, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#3a08078c]
2020-12-08 17:34:14.874 INFO 7236 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8085 (http) with context path ''
2020-12-08 17:34:14.884 INFO 7236 --- [ main] DeferredRepositoryInitializationListener : Triggering deferred initialization of Spring Data repositories…
2020-12-08 17:34:14.889 INFO 7236 --- [ task-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-12-08 17:34:14.948 INFO 7236 --- [ task-1] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
2020-12-08 17:34:18.480 INFO 7236 --- [ task-1] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-12-08 17:34:18.495 INFO 7236 --- [ task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-12-08 17:34:18.881 INFO 7236 --- [ main] DeferredRepositoryInitializationListener : Spring Data repositories initialized!
2020-12-08 17:34:18.890 INFO 7236 --- [ main] c.regestration.RegestrationApplication : Started RegestrationApplication in 13.562 seconds (JVM running for 19.799)
2020-12-08 17:34:42.030 INFO 7236 --- [nio-8085-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-12-08 17:34:42.031 INFO 7236 --- [nio-8085-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-12-08 17:34:42.050 INFO 7236 --- [nio-8085-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 19 ms
controller
package com.regestration.controller;
import java.util.HashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.regestration.repository.Repository;
import com.regestration.user.User;
#RestController
public class Controller {
#Autowired
Repository repo;
#RequestMapping(value="/saveReg", method= RequestMethod.POST)
public HashMap<String, Object>saveRegestration(#RequestBody User user){
HashMap<String, Object> map = new HashMap<String, Object>();
repo.save(user);
map.put("code", "200");
map.put("code", "saved");
return map;
}
}
application.properties
spring.datasource.url= jdbc:mysql://localhost:3306/myshadi?useSSL=false
spring.datasource.username= root
spring.datasource.password= root
spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.MySQL5InnoDBDialect
# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto= update
server.port=8085
Spring is activating by default the security.
See line : Using generated security password: 7406d0eb-72dc-4ce4-a8cc-220d3c523098.
You have to inactivate the security if you don't need it : Spring boot Security Disable security

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})

Resources