why spring.jpa.hibernate.ddl-auto set update but schema.sql and data.sql still executing? - spring

I use schema.sql and data.sql at developing step, but I need to release a version to the server, so I modify the ddl-auto=none to ddl-auto=update, But after I re-execute, schema.sql and data.sql are still executed, why?
there's my config:
server:
port: 8081
spring:
jpa:
hibernate:
ddl-auto: update
show-sql: true
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
profiles:
active: prod
and here is my log:
2020-05-26 12:57:49.412 INFO 3642 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executing SQL script from URL [file:/Users/shawnwu4mac/IdeaProjects/UTM-system-LSTM/target/classes/schema.sql]
2020-05-26 12:57:52.587 INFO 3642 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executed SQL script from URL [file:/Users/shawnwu4mac/IdeaProjects/UTM-system-LSTM/target/classes/schema.sql] in 3175 ms.
2020-05-26 12:57:52.592 INFO 3642 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executing SQL script from URL [file:/Users/shawnwu4mac/IdeaProjects/UTM-system-LSTM/target/classes/data.sql]
2020-05-26 12:57:53.785 INFO 3642 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executed SQL script from URL [file:/Users/shawnwu4mac/IdeaProjects/UTM-system-LSTM/target/classes/data.sql] in 1193 ms.
2020-05-26 12:57:53.962 INFO 3642 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2020-05-26 12:57:53.972 INFO 3642 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2020-05-26 12:57:54.028 INFO 3642 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final}
2020-05-26 12:57:54.029 INFO 3642 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2020-05-26 12:57:54.030 INFO 3642 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2020-05-26 12:57:54.060 INFO 3642 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2020-05-26 12:57:54.137 INFO 3642 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
2020-05-26 12:57:54.527 INFO 3642 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000228: Running hbm2ddl schema update
2020-05-26 12:58:00.756 INFO 3642 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'

you must also add below property for your yml. it works well for me.
spring:
jpa:
generate-ddl: true

Related

Spring not showing logs for schema.sql

I am learning spring boot by working on a spring project and attempting to use h2 as an embedded database. Below are the details:
Project Structure:
application.properties file contain:
logging.level.springframework.jdbc.datasource.init.ScriptUtils=debug
spring.jpa.hibernate.ddl-auto=none
The problem is spring boot doesn't show logs for queries inside schema.sql and data.sql.
Logs for reference:
INFO 19121 --- [ main] c.v.l.l.LearningSpringApplication : No active profile set, falling back to default profiles: default
INFO 19121 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
INFO 19121 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 10 ms. Found 0 JPA repository interfaces.
INFO 19121 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
INFO 19121 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
INFO 19121 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.54]
INFO 19121 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
INFO 19121 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1534 ms
INFO 19121 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
INFO 19121 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
INFO 19121 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
INFO 19121 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.32.Final
INFO 19121 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
INFO 19121 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
INFO 19121 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
INFO 19121 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
WARN 19121 --- [ 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
INFO 19121 --- [ main] o.s.b.a.w.s.WelcomePageHandlerMapping : Adding welcome page: class path resource [static/index.html]
INFO 19121 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
INFO 19121 --- [ main] c.v.l.l.LearningSpringApplication : Started LearningSpringApplication in 3.858 seconds (JVM running for 4.364)
If you use h2 inmemory db with spring-data-jpa, you can see all query in console when hibernate use query to db.
You can see query by add spring.jpa.properties.hibernate.show_sql=true in application.properties.

Spring boot docker running on 8080 only?

I have deployed my spring boot application on docker but when I am trying to run it, it is only running on 8080 port not any other port i.e 3000 from logs I am able to deduce that it has something to do with internal tomcat listens to 8080 port. can anyone please tell me what is happening inside?
below are the logs when I am running on 8080
2021-02-14 05:53:36.156 INFO 1 --- [ main] com.ebi.uk.EbiProjectJavaApplication : Starting EbiProjectJavaApplication v0.0.1-SNAPSHOT using Java 1.8.0_212 on 8a710deb6884 with PID 1 (/ebiProjectJava.jar started by root in /)
2021-02-14 05:53:36.160 INFO 1 --- [ main] com.ebi.uk.EbiProjectJavaApplication : No active profile set, falling back to default profiles: default
2021-02-14 05:53:37.426 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-02-14 05:53:37.663 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 224 ms. Found 1 JPA repository interfaces.
2021-02-14 05:53:38.750 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2021-02-14 05:53:38.770 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-02-14 05:53:38.771 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.41]
2021-02-14 05:53:38.902 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-02-14 05:53:38.903 INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2621 ms
2021-02-14 05:53:39.139 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-02-14 05:53:39.648 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-02-14 05:53:39.732 INFO 1 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-02-14 05:53:39.817 INFO 1 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.27.Final
2021-02-14 05:53:39.990 INFO 1 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-02-14 05:53:40.149 INFO 1 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2021-02-14 05:53:40.898 INFO 1 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-02-14 05:53:40.909 INFO 1 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-02-14 05:53:41.299 WARN 1 --- [ 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
2021-02-14 05:53:41.595 INFO 1 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2021-02-14 05:53:42.091 INFO 1 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#7b94089b, org.springframework.security.web.context.SecurityContextPersistenceFilter#ee86bcb, org.springframework.security.web.header.HeaderWriterFilter#1f010bf0, org.springframework.security.web.authentication.logout.LogoutFilter#bcef303, org.springframework.security.web.authentication.www.BasicAuthenticationFilter#33308786, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#7f132176, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#6ed3f258, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#7ca20101, org.springframework.security.web.session.SessionManagementFilter#10cf09e8, org.springframework.security.web.access.ExceptionTranslationFilter#19b93fa8, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#71812481]
2021-02-14 05:53:42.410 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2021-02-14 05:53:42.424 INFO 1 --- [ main] com.ebi.uk.EbiProjectJavaApplication : Started EbiProjectJavaApplication in 6.864 seconds (JVM running for 7.751)
2021-02-14 05:54:13.163 INFO 1 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2021-02-14 05:54:13.164 INFO 1 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2021-02-14 05:54:13.167 INFO 1 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 3 ms
below are the logs when I am trying to run on 3000
2021-02-14 05:50:58.993 INFO 1 --- [ main] com.ebi.uk.EbiProjectJavaApplication : Starting EbiProjectJavaApplication v0.0.1-SNAPSHOT using Java 1.8.0_212 on b0f62c63fde2 with PID 1 (/ebiProjectJava.jar started by root in /)
2021-02-14 05:50:58.997 INFO 1 --- [ main] com.ebi.uk.EbiProjectJavaApplication : No active profile set, falling back to default profiles: default
2021-02-14 05:51:00.304 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-02-14 05:51:00.566 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 243 ms. Found 1 JPA repository interfaces.
2021-02-14 05:51:01.714 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2021-02-14 05:51:01.734 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-02-14 05:51:01.734 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.41]
2021-02-14 05:51:01.816 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-02-14 05:51:01.817 INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2706 ms
2021-02-14 05:51:02.060 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-02-14 05:51:02.534 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-02-14 05:51:02.632 INFO 1 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-02-14 05:51:02.723 INFO 1 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.27.Final
2021-02-14 05:51:02.909 INFO 1 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-02-14 05:51:03.163 INFO 1 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2021-02-14 05:51:04.045 INFO 1 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-02-14 05:51:04.055 INFO 1 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-02-14 05:51:04.480 WARN 1 --- [ 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
2021-02-14 05:51:04.799 INFO 1 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2021-02-14 05:51:05.330 INFO 1 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#7ca20101, org.springframework.security.web.context.SecurityContextPersistenceFilter#177bea38, org.springframework.security.web.header.HeaderWriterFilter#40db2a24, org.springframework.security.web.authentication.logout.LogoutFilter#41709512, org.springframework.security.web.authentication.www.BasicAuthenticationFilter#4f9a2c08, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#6bca7e0d, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#8ad6665, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#47f9738, org.springframework.security.web.session.SessionManagementFilter#1921ad94, org.springframework.security.web.access.ExceptionTranslationFilter#7e6ef134, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#16ce702d]
2021-02-14 05:51:05.709 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2021-02-14 05:51:05.726 INFO 1 --- [ main] com.ebi.uk.EbiProjectJavaApplication : Started EbiProjectJavaApplication in 7.436 seconds (JVM running for 8.28)
below is my pom.xml
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- <dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency> -->
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency> -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- spring security test -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mysql</artifactId>
<scope>test</scope>
</dependency>
below is the command I am trying to run
docker run -p 3000:3000 ebiproject
I think you are missing important concept here. 8080 is default port for spring boot application. But, in your docker network configuration you mapped 3000 -> 3000 which is wrong.
Instead, you should configure like below:
docker run -p 3000:8080 ebiproject

Unexpected Web-Application closing immediately after starting

These are the current dependencies included in my web application.
dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-data-rest")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-web-services")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("com.google.firebase:firebase-admin:6.10.0")
}
Every time I run the application I get the following error:
2019-09-30 13:32:38.385 INFO 17104 --- [ restartedMain] unito.taas.project.ProjectApplicationKt : Starting ProjectApplicationKt on LAPTOP-K1DHEJQ6 with PID 17104 (C:\Users\beppe\Desktop\project\TAAS_project\project\build\classes\kotlin\main started by beppe in C:\Users\beppe\Desktop\project\TAAS_project)
2019-09-30 13:32:38.388 INFO 17104 --- [ restartedMain] unito.taas.project.ProjectApplicationKt : No active profile set, falling back to default profiles: default
2019-09-30 13:32:38.444 INFO 17104 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2019-09-30 13:32:39.177 INFO 17104 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-09-30 13:32:39.263 INFO 17104 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 77ms. Found 3 repository interfaces.
2019-09-30 13:32:39.785 INFO 17104 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2019-09-30 13:32:39.976 INFO 17104 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2019-09-30 13:32:40.045 INFO 17104 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2019-09-30 13:32:40.127 INFO 17104 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate Core {5.3.11.Final}
2019-09-30 13:32:40.128 INFO 17104 --- [ restartedMain] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2019-09-30 13:32:40.317 INFO 17104 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
2019-09-30 13:32:40.734 INFO 17104 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2019-09-30 13:32:41.419 INFO 17104 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-09-30 13:32:41.439 INFO 17104 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2019-09-30 13:32:43.049 INFO 17104 --- [ restartedMain] unito.taas.project.ProjectApplicationKt : Started ProjectApplicationKt in 5.053 seconds (JVM running for 5.806)
2019-09-30 13:32:43.063 INFO 17104 --- [ Thread-9] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2019-09-30 13:32:43.068 INFO 17104 --- [ Thread-9] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2019-09-30 13:32:43.073 INFO 17104 --- [ Thread-9] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
How can I avoid the application closing?
EDIT:
The following is my SpringBoot annotated class
package unito.taas.project
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
#SpringBootApplication
class ProjectApplication
fun main(args: Array<String>) {
runApplication<ProjectApplication>(*args)
}

Can't override bootstrap.properties when run with other profile

I'm trying to run my Spring Boot in local profile with bootstrap-local.properties but It seems not working.
In src/main/resourses I have 2 file: bootstrap.properties and bootstrap-local.properties.
bootstrap.properties
#Application Name
spring.application.name=configserver
#Server port
server.port=8888
# Github URL to connect remote Repository
spring.cloud.config.server.git.uri=https://github.com/TranNgocKhoa/config-respo
# Search path in the remote Repository
spring.cloud.config.server.git.search-paths=config-files*
bootstrap-local.properties
#Application Name
spring.application.name=configserver
#Server port
server.port=8888
# Github URL to connect remote Repository
spring.cloud.config.server.native.search-locations=classpath:/config-respo/config-files
But when I run it with local profile:
2019-03-22 11:20:14.398 INFO 11676 --- [ main] c.h.c.HellodoctorConfigserverApplication : The following profiles are active: local
2019-03-22 11:20:15.185 INFO 11676 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=ce04fc74-ea60-3e26-a1e0-957e7be20901
2019-03-22 11:20:15.210 INFO 11676 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$74797a93] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-22 11:20:15.489 INFO 11676 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8888 (http)
2019-03-22 11:20:15.514 INFO 11676 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-03-22 11:20:15.514 INFO 11676 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.16]
2019-03-22 11:20:15.523 INFO 11676 --- [ 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: [C:\Program Files\Java\jdk1.8.0_201\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\ProgramData\DockerDesktop\version-bin;C:\Program Files\Docker\Docker\Resources\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Java\jdk1.8.0_201\bin;C:\Program Files\PowerShell\6-preview\preview;C:\Program Files (x86)\VietPN;C:\Program Files\nodejs\;C:\Program Files\apache-maven-3.6.0\bin;C:\Program Files\Git\cmd;C:\Users\khoa1\AppData\Local\Programs\Python\Python37\Scripts\;C:\Users\khoa1\AppData\Local\Programs\Python\Python37\;C:\Users\khoa1\AppData\Local\Microsoft\WindowsApps;;C:\Program Files\JetBrains\IntelliJ IDEA 2018.3.3\bin;;C:\Users\khoa1\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\khoa1\AppData\Roaming\npm;.]
2019-03-22 11:20:15.631 INFO 11676 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-03-22 11:20:15.631 INFO 11676 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1222 ms
2019-03-22 11:20:17.030 INFO 11676 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-03-22 11:20:18.049 INFO 11676 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator'
2019-03-22 11:20:18.159 INFO 11676 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8888 (http) with context path ''
2019-03-22 11:20:18.162 INFO 11676 --- [ main] c.h.c.HellodoctorConfigserverApplication : Started HellodoctorConfigserverApplication in 7.492 seconds (JVM running for 9.255)
2019-03-22 11:20:19.073 INFO 11676 --- [on(1)-10.0.75.1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-03-22 11:20:19.073 INFO 11676 --- [on(1)-10.0.75.1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2019-03-22 11:20:19.082 INFO 11676 --- [on(1)-10.0.75.1] o.s.web.servlet.DispatcherServlet : Completed initialization in 9 ms
When I request to get a configuration, I get a config data that corresponding with when I run in default profile:
http://localhost:8888/hellodoctor-test-service/local
"name": "hellodoctor-test-service",
"profiles": [
"local"
],
"label": null,
"version": "826b53db8aa62950cc42030ba19da8c1a39d3bc7",
"state": null,
"propertySources": [
{
"name": "https://github.com/TranNgocKhoa/config-respo/config-files/hellodoctor-test-service.yml",
"source": {
"spring.zipkin.baseUrl": "http://tracing-server:9411",
"spring.application.name": "hellodoctor-test-service",
"server.port": 8082,
"eureka.client.serviceUrl.defaultZone": "http://${DNS_DISCOVERY_SERVER}:8761/eureka/"
}
}
]
}
You can see that in config data: name": "https://github.com/TranNgocKhoa/config-respo/config-files/hellodoctor-test-service.yml
I'd like to get from local repository.
How can I fix it?
Thank you.

Force to drop the JPA Database

I am using a Spring MVC server and i need to drop the database.
I use this configuration on application.properties:
spring.datasource.url=jdbc:h2:~/test;AUTO_SERVER=TRUE
spring.datasource.driverClassName=org.h2.Driver
spring.jpa.show-sql: true
spring.jpa.hibernate.ddl-auto=create-drop
And I ensure that it is used typing that in the Application's annotation:
#PropertySource("application.properties")
But the tables are not dropped, just they are loaded normally:
2014-11-18 13:30:28.231 INFO 7472 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2014-11-18 13:30:28.250 INFO 7472 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2014-11-18 13:30:28.306 INFO 7472 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {4.3.1.Final}
2014-11-18 13:30:28.307 INFO 7472 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2014-11-18 13:30:28.308 INFO 7472 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2014-11-18 13:30:28.471 INFO 7472 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
2014-11-18 13:30:32.894 INFO 7472 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2014-11-18 13:30:33.010 INFO 7472 --- [ main] o.h.h.i.ast.ASTQueryTranslatorFactory : HHH000397: Using ASTQueryTranslatorFactory
2014-11-18 13:30:33.280 INFO 7472 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000228: Running hbm2ddl schema update
2014-11-18 13:30:33.280 INFO 7472 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000102: Fetching database metadata
2014-11-18 13:30:33.281 INFO 7472 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000396: Updating schema
2014-11-18 13:30:33.289 INFO 7472 --- [ main] o.hibernate.tool.hbm2ddl.TableMetadata : HHH000261: Table found: TEST.PUBLIC.CLIENTE
2014-11-18 13:30:33.289 INFO 7472 --- [ main] o.hibernate.tool.hbm2ddl.TableMetadata : HHH000037: Columns: [creation_date, id, complete_name, logginname, loggin_name]
2014-11-18 13:30:33.289 INFO 7472 --- [ main] o.hibernate.tool.hbm2ddl.TableMetadata : HHH000108: Foreign keys: []
2014-11-18 13:30:33.289 INFO 7472 --- [ main] o.hibernate.tool.hbm2ddl.TableMetadata : HHH000126: Indexes: [primary_key_9]
etc...
I need to force for deleting the database.
You should try setting spring.jpa.hibernate.hbm2ddl.auto=create-drop as per this question.
Also note you need to set the generateDdl to false, due to https://jira.spring.io/browse/SPR-6836 .

Resources