Debugging does not step into function Spring REST Service #Controller with curl - spring

I've a Spring Version: 3.6.3.RELEASE Project with a REST Service and I want to debug the #RequestMapping #Controller class by initiating a request throug curl.
Ive set debugging Breakepoints in the function of the #RequestMapping
and Ive started the project in debug mode ....
and everything is starting up fine .....
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.0.1.RELEASE)
2015-03-08 11:38:00.288 INFO 4252 --- [ main] com.pekam.Application : Starting Application on KABUL with PID 4252 (C:\Users\pk\Documents\workspace-sts-3.6.3.RELEASE\MyRestDataRepository\target\classes started by pk)
2015-03-08 11:38:00.333 INFO 4252 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#6b6776cb: startup date [Sun Mar 08 11:38:00 CET 2015]; root of context hierarchy
2015-03-08 11:38:00.682 INFO 4252 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'org.springframework.boot.autoconfigure.AutoConfigurationPackages': replacing [Generic bean: class [org.springframework.boot.autoconfigure.AutoConfigurationPackages$BasePackages]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] with [Generic bean: class [org.springframework.boot.autoconfigure.AutoConfigurationPackages$BasePackages]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null]
2015-03-08 11:38:01.140 INFO 4252 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$3fc9350d] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-03-08 11:38:01.162 INFO 4252 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionAttributeSource' of type [class org.springframework.transaction.annotation.AnnotationTransactionAttributeSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-03-08 11:38:01.172 INFO 4252 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionInterceptor' of type [class org.springframework.transaction.interceptor.TransactionInterceptor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-03-08 11:38:01.179 INFO 4252 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.config.internalTransactionAdvisor' of type [class org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-03-08 11:38:01.380 INFO 4252 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Server initialized with port: 8080
2015-03-08 11:38:01.523 INFO 4252 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2015-03-08 11:38:01.523 INFO 4252 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/7.0.52
2015-03-08 11:38:01.640 INFO 4252 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2015-03-08 11:38:01.640 INFO 4252 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1310 ms
2015-03-08 11:38:02.103 INFO 4252 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2015-03-08 11:38:02.105 INFO 4252 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2015-03-08 11:38:02.353 INFO 4252 --- [ main] o.s.j.d.DriverManagerDataSource : Loaded JDBC driver: org.h2.Driver
2015-03-08 11:38:02.353 INFO 4252 --- [ main] o.s.j.d.DriverManagerDataSource : Loaded JDBC driver: com.microsoft.sqlserver.jdbc.SQLServerDriver
2015-03-08 11:38:02.353 INFO 4252 --- [ main] o.s.j.d.DriverManagerDataSource : Loaded JDBC driver: com.mysql.jdbc.Driver
2015-03-08 11:38:02.493 INFO 4252 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2015-03-08 11:38:02.514 INFO 4252 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2015-03-08 11:38:02.590 INFO 4252 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {4.3.1.Final}
2015-03-08 11:38:02.592 INFO 4252 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2015-03-08 11:38:02.594 INFO 4252 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2015-03-08 11:38:02.795 INFO 4252 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
2015-03-08 11:38:03.064 INFO 4252 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
2015-03-08 11:38:03.181 INFO 4252 --- [ main] o.h.h.i.ast.ASTQueryTranslatorFactory : HHH000397: Using ASTQueryTranslatorFactory
2015-03-08 11:38:03.510 INFO 4252 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000228: Running hbm2ddl schema update
2015-03-08 11:38:03.510 INFO 4252 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000102: Fetching database metadata
2015-03-08 11:38:03.516 INFO 4252 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000396: Updating schema
2015-03-08 11:38:03.533 INFO 4252 --- [ main] o.hibernate.tool.hbm2ddl.TableMetadata : HHH000261: Table found: test.tblgps
2015-03-08 11:38:03.533 INFO 4252 --- [ main] o.hibernate.tool.hbm2ddl.TableMetadata : HHH000037: Columns: [date, descr, provider, lon, id, deviceid, userid, lat]
2015-03-08 11:38:03.533 INFO 4252 --- [ main] o.hibernate.tool.hbm2ddl.TableMetadata : HHH000108: Foreign keys: []
2015-03-08 11:38:03.533 INFO 4252 --- [ main] o.hibernate.tool.hbm2ddl.TableMetadata : HHH000126: Indexes: [primary]
2015-03-08 11:38:03.534 INFO 4252 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000232: Schema update complete
2015-03-08 11:38:03.941 INFO 4252 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-03-08 11:38:04.064 INFO 4252 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/TblGps/List/],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.util.List<com.pekam.TblGps> com.pekam.TblGpsController.findAll()
2015-03-08 11:38:04.064 INFO 4252 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/TblGps/get],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public com.pekam.TblGps com.pekam.TblGpsController.findById(long)
2015-03-08 11:38:04.064 INFO 4252 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/TblGps/update3/],methods=[POST],params=[],headers=[],consumes=[*/*],produces=[application/json || */*],custom=[]}" onto public com.pekam.TblGps com.pekam.TblGpsController.post1(com.pekam.TblGps)
2015-03-08 11:38:04.064 INFO 4252 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/TblGps/update],methods=[POST],params=[],headers=[],consumes=[*/*],produces=[*/*],custom=[]}" onto public com.pekam.TblGps com.pekam.TblGpsController.post(com.pekam.TblGps)
2015-03-08 11:38:04.065 INFO 4252 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/*],methods=[GET || POST || DELETE || PUT || HEAD],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.pekam.TblGpsController.allFallback()
2015-03-08 11:38:04.065 INFO 4252 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/TblGps/update2/],methods=[POST],params=[],headers=[],consumes=[*/*],produces=[*/*],custom=[]}" onto public java.lang.String com.pekam.TblGpsController.post2(java.lang.String)
2015-03-08 11:38:04.093 INFO 4252 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-03-08 11:38:04.094 INFO 4252 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-03-08 11:38:04.161 INFO 4252 --- [ main] .m.m.a.ExceptionHandlerExceptionResolver : Detected #ExceptionHandler methods in restResponseEntityExceptionHandler
2015-03-08 11:38:04.345 INFO 4252 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2015-03-08 11:38:04.378 INFO 4252 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080/http
2015-03-08 11:38:04.380 INFO 4252 --- [ main] com.pekam.Application : Started Application in 4.383 seconds (JVM running for 4.904)
but when i execute the Request with curl the debuger does not step into the function.
C:\Users\pk>curl -H "Content-Type:application/json" -d {"date":1425811355985,"de
scr":null,"deviceID":"1","provider":"fused","id":0,"lat":4.0,"userid":1,"lon":4.
0} http://127.0.0.1:8080/TblGps/update
The curl output is: just nothing
It seems linke the debugger is not properly attached to the process but when i change my curl request to bad mapping entry STS is showing me the errors on the console debugging windows.
any Ideas appreciated !!
code
#Controller
public class TblGpsController {
private static final Logger logger = LoggerFactory.getLogger(TblGpsController.class);
#RequestMapping(value = "*", method = { RequestMethod.GET, RequestMethod.POST ,RequestMethod.DELETE,RequestMethod.PUT,RequestMethod.HEAD })
#ResponseBody
public String allFallback() {
return "Fallback for All Requests";
}
#RequestMapping(value="/TblGps/update", method=RequestMethod.POST,consumes = MediaType.ALL_VALUE,produces= MediaType.ALL_VALUE)
#ResponseBody public TblGps post(#RequestParam("object") TblGps gps){
return Application.DataRepository.save(gps);
}

You need to use #RequestParam annotation if you are posting JSON data. Its annotation that needs to be used if you want to parse the data in the request body which in your case is json data sent as post.
#ResponseBody public TblGps post(#RequestBody TblGps gps){
return Application.DataRepository.save(gps);
}

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.

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.

The hibernate.properties file doesn't change the hibernate dialect

I have created a spring application with MySql db connected and I want the hibernate to create tables using Innodb engine but it always creates the table using MyISAM engine.
the application.properties file:
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:3306/spring?autoReconnect=true&useSSL=false
spring.datasource.username=root
spring.datasource.password=
The hibernate.properties file:
hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
hibernate.dialect.storage_engine=innodb
The console output:
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.3.RELEASE)
2017-12-18 13:54:19.460 INFO 9144 --- [ main] hello.Application : Starting Application on webc13 with PID 9144 (C:\spring\gs-rest-service\complete\build\classes\main started by Arielb in C:\spring\gs-rest-service\complete)
2017-12-18 13:54:19.465 INFO 9144 --- [ main] hello.Application : No active profile set, falling back to default profiles: default
2017-12-18 13:54:19.506 INFO 9144 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#44a3ec6b: startup date [Mon Dec 18 13:54:19 IST 2017]; root of context hierarchy
2017-12-18 13:54:20.802 WARN 9144 --- [ main] o.h.v.m.ParameterMessageInterpolator : HV000184: ParameterMessageInterpolator has been chosen, EL interpolation will not be supported
2017-12-18 13:54:21.102 WARN 9144 --- [ main] o.h.v.m.ParameterMessageInterpolator : HV000184: ParameterMessageInterpolator has been chosen, EL interpolation will not be supported
2017-12-18 13:54:21.371 INFO 9144 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-12-18 13:54:21.380 INFO 9144 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-12-18 13:54:21.381 INFO 9144 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.14
2017-12-18 13:54:21.517 INFO 9144 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-12-18 13:54:21.518 INFO 9144 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2014 ms
2017-12-18 13:54:21.634 INFO 9144 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-12-18 13:54:21.638 INFO 9144 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-12-18 13:54:21.639 INFO 9144 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-12-18 13:54:21.639 INFO 9144 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-12-18 13:54:21.639 INFO 9144 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-12-18 13:54:22.051 INFO 9144 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2017-12-18 13:54:22.060 INFO 9144 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2017-12-18 13:54:22.114 INFO 9144 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final}
2017-12-18 13:54:22.116 INFO 9144 --- [ main] org.hibernate.cfg.Environment : HHH000205: Loaded properties from resource hibernate.properties: {hibernate.dialect=org.hibernate.dialect.MySQLMyISAMDialect, spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLMyISAMDialect, hibernate.bytecode.use_reflection_optimizer=false, hibernate.dialect.storage_engine=myisam}
2017-12-18 13:54:22.117 INFO 9144 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2017-12-18 13:54:22.151 INFO 9144 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2017-12-18 13:54:22.236 INFO 9144 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2017-12-18 13:54:22.527 INFO 9144 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000228: Running hbm2ddl schema update
2017-12-18 13:54:22.555 INFO 9144 --- [ main] rmationExtractorJdbcDatabaseMetaDataImpl : HHH000262: Table not found: logs
2017-12-18 13:54:22.555 INFO 9144 --- [ main] rmationExtractorJdbcDatabaseMetaDataImpl : HHH000262: Table not found: logs
2017-12-18 13:54:22.741 INFO 9144 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2017-12-18 13:54:23.178 INFO 9144 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#44a3ec6b: startup date [Mon Dec 18 13:54:19 IST 2017]; root of context hierarchy
2017-12-18 13:54:23.231 INFO 9144 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/dd/one/{id}],methods=[GET]}" onto public hello.Files hello.controller.InspectorController.getFile(java.lang.Integer)
2017-12-18 13:54:23.232 INFO 9144 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/dd/all],methods=[GET]}" onto public java.lang.Iterable<hello.Files> hello.controller.InspectorController.getAllUsers()
2017-12-18 13:54:23.232 INFO 9144 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/dd/insert],methods=[POST]}" onto public hello.Files hello.controller.InspectorController.saveFiles(java.lang.String,java.util.Date,java.lang.String,java.lang.String,javax.servlet.http.HttpServletRequest) throws javassist.tools.web.BadHttpRequest
2017-12-18 13:54:23.232 INFO 9144 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/greeting]}" onto public hello.Greeting hello.GreetingController.greeting(java.lang.String)
2017-12-18 13:54:23.234 INFO 9144 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2017-12-18 13:54:23.234 INFO 9144 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2017-12-18 13:54:23.259 INFO 9144 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-12-18 13:54:23.259 INFO 9144 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-12-18 13:54:23.287 INFO 9144 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-12-18 13:54:23.459 INFO 9144 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-12-18 13:54:23.504 INFO 9144 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-12-18 13:54:23.508 INFO 9144 --- [ main] hello.Application : Started Application in 4.291 seconds (JVM running for 4.77)
Any idea?
Edit
finally, the only way I managed to reach the desired engine was to set the my.conf file:
default-storage-engine=InnoDB
According to this post, the MySQL5InnoDBDialect has been deprecated, the class to use is MySQL5Dialect.
So you need to change the dialect :
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.dialect.storage_engine=innodb
If it doesn't work, try using the spring jpa properties :
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
change your hibernate.properties file to
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.dialect.storage_engine=innodb
and then try it. MySQL5InnoDBDialect is deprecated .
spring.jpa.database-platform: org.hibernate.dialect.MySQL57InnoDBDialect work for me, but MySQL57InnoDBDialect was marked as deprecated.
It suggested that using hibernate.dialect.storage_engine=innodb but it is not working for me.
So I keep MySQL57InnoDBDialect.

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