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.
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.
I am trying to run a project which is not created here, but imported into this PC.
I switched its database from MySQL to PostgreSQL, and now it's not executing completely. It's stopping here:
:: Spring Boot :: (v1.5.10.RELEASE)
2018-09-14 10:35:34.688 INFO 14924 --- [ main] com.magnus.MagnusItApplication : Starting MagnusItApplication on CHETNALE22674 with PID 14924 (D:\MagnusIT-master\target\classes started by adarsh.singh in D:\MagnusIT-master)
2018-09-14 10:35:34.688 INFO 14924 --- [ main] com.magnus.MagnusItApplication : No active profile set, falling back to default profiles: default
2018-09-14 10:35:34.766 INFO 14924 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#3c87521: startup date [Fri Sep 14 10:35:34 IST 2018]; root of context hierarchy
2018-09-14 10:35:35.816 INFO 14924 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$d64197d4] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-09-14 10:35:36.146 INFO 14924 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 9090 (http)
2018-09-14 10:35:36.177 INFO 14924 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-09-14 10:35:36.177 INFO 14924 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.27
2018-09-14 10:35:36.333 INFO 14924 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-09-14 10:35:36.333 INFO 14924 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1567 ms
2018-09-14 10:35:36.474 INFO 14924 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-09-14 10:35:36.474 INFO 14924 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-09-14 10:35:36.474 INFO 14924 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-09-14 10:35:36.474 INFO 14924 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-09-14 10:35:36.474 INFO 14924 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2018-09-14 10:35:36.474 INFO 14924 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
Here is its application.properties:
server.port= 9090
spring.datasource.url= jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=postgres
spring.datasource.password=npci#123
spring.jpa.hibernate.ddl-auto=update
spring.datasource.driverClassName=org.postgresql.Driver
#spring.datasource.url = jdbc:mysql://localhost:3306/magnus
#spring.datasource.username=root
#spring.datasource.password=root
#spring.datasource.driverClassName=com.mysql.jdbc.Driver
#spring.jpa.hibernate.ddl-auto=update
logging.level.root=info
logging.pattern.file=%d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M - %msg%n
logging.level.com.restcrud.emp=debug
logging.path=logs
logging.file=${logging.path}/crudlog.log
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=team.magnus.it
spring.mail.password=team#magnus
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
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);
}
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 .