I have issues with recent Springboot 2.3 release.
I have the following config class:
package name.defance.springbootdemo.security;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
#Configuration
public class SampleConfig {
#Autowired
public SampleConfig(DataSource dataSource) {
System.out.println("DATASOURCE: " + dataSource);
this.dataSource = dataSource;
}
final private DataSource dataSource;
}
With version 2.2.7 I have the following output:
<... truncated output ...>
2020-05-18 17:57:33.872 INFO 2081 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-05-18 17:57:33.873 INFO 2081 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.34]
2020-05-18 17:57:33.950 INFO 2081 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-05-18 17:57:33.950 INFO 2081 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2113 ms
2020-05-18 17:57:34.511 INFO 2081 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-05-18 17:57:34.555 INFO 2081 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.15.Final
2020-05-18 17:57:34.686 INFO 2081 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-05-18 17:57:34.801 INFO 2081 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-05-18 17:57:34.901 INFO 2081 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-05-18 17:57:34.922 INFO 2081 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL10Dialect
2020-05-18 17:57:35.405 INFO 2081 --- [ restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-05-18 17:57:35.411 INFO 2081 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-05-18 17:57:35.463 WARN 2081 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : Unable to start LiveReload server
DATASOURCE: HikariDataSource (HikariPool-1)
<... truncated output ...>
With version 2.3.0.RELEASE I have the following:
<... truncated output ...>
2020-05-18 17:52:02.183 INFO 352 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-05-18 17:52:02.184 INFO 352 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.35]
2020-05-18 17:52:02.249 INFO 352 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-05-18 17:52:02.249 INFO 352 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2453 ms
2020-05-18 17:52:02.669 INFO 352 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
DATASOURCE: HikariDataSource (null)
2020-05-18 17:52:02.720 INFO 352 --- [ task-1] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-05-18 17:52:02.755 INFO 352 --- [ task-1] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.15.Final
2020-05-18 17:52:02.862 INFO 352 --- [ task-1] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-05-18 17:52:02.957 INFO 352 --- [ task-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-05-18 17:52:03.066 INFO 352 --- [ task-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-05-18 17:52:03.081 INFO 352 --- [ task-1] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL10Dialect
2020-05-18 17:52:03.526 INFO 352 --- [ task-1] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-05-18 17:52:03.534 INFO 352 --- [ task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-05-18 17:52:03.736 WARN 352 --- [ task-2] o.s.b.d.a.OptionalLiveReloadServer : Unable to start LiveReload server
<... truncated output ...>
The only difference between those is (in pom.xml):
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
vs
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
So with the new release datasource bean is configured in a separate thread, and my configuration bean received not-yet configured DataSource bean (null).
I cannot find any reference to configuration flow changes in release notes. What is wrong here, and why my code stopped working?
UPDATE. I reproduced this issue once more with Spring initializer. Options selected: Java 14, actuator, jdbc, web, devtools, postgres db driver
Application properties contains all the correct connection data (verified on other old-spring project). Its only contents is:
spring.datasource.url=jdbc:postgresql://localhost:15432/insurance-demo
spring.datasource.username=postgres
spring.datasource.password=postgresPWD
server.port=8080
Update: Project repo https://github.com/defance/datasource-demo
It looks like 'spring-boot-starter-data-jpa' can be added to the dependency set to bring the hikari pool start back to the same point it was before.
Using your repository, I added this section to the pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
and the result:
2020-05-18 09:58:17.046 INFO 60543 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-05-18 09:58:17.094 INFO 60543 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
DATASOURCE: HikariDataSource (HikariPool-1)
Here is the doc section about data source configuration that I followed:
https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-sql
Related
the application stands up but the graphql end point is not produced. I generated this project on start.spring.io but originally settings is the graphql end point not produced
application.yml
datasource:
url: jdbc:postgresql://localhost:10000/postgres
username: admin
password: 12345
graphql:
graphiql:
enabled: true
log
2022-07-07 09:44:40.006 INFO 10960 --- [ restartedMain] c.i.e.EmployeeManagmentApplication : No active profile set, falling back to 1 default profile: "default"
2022-07-07 09:44:40.173 INFO 10960 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2022-07-07 09:44:40.173 INFO 10960 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2022-07-07 09:44:41.787 INFO 10960 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode
2022-07-07 09:44:41.788 INFO 10960 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-07-07 09:44:41.823 INFO 10960 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 13 ms. Found 0 JPA repository interfaces.
2022-07-07 09:44:41.866 INFO 10960 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode
2022-07-07 09:44:41.869 INFO 10960 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode.
2022-07-07 09:44:41.891 INFO 10960 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 2 ms. Found 0 Redis repository interfaces.
2022-07-07 09:44:43.152 INFO 10960 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-07-07 09:44:43.168 INFO 10960 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-07-07 09:44:43.168 INFO 10960 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.64]
2022-07-07 09:44:43.326 INFO 10960 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-07-07 09:44:43.326 INFO 10960 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3149 ms
2022-07-07 09:44:43.500 INFO 10960 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2022-07-07 09:44:43.722 INFO 10960 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2022-07-07 09:44:43.794 INFO 10960 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2022-07-07 09:44:43.927 INFO 10960 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.9.Final
2022-07-07 09:44:44.284 INFO 10960 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2022-07-07 09:44:44.547 INFO 10960 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL10Dialect
2022-07-07 09:44:44.780 INFO 10960 --- [ restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2022-07-07 09:44:44.793 INFO 10960 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2022-07-07 09:44:44.903 WARN 10960 --- [ restartedMain] 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-07-07 09:44:46.688 INFO 10960 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2022-07-07 09:44:46.779 INFO 10960 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2022-07-07 09:44:46.805 INFO 10960 --- [ restartedMain] c.i.e.EmployeeManagmentApplication : Started EmployeeManagmentApplication in 7.652 seconds (JVM running for 10.128)```
pom.xml
From my understanding using #SpringBootApplication is the equivalent of having #EnableAutoConfiguration and #ComponentScan. For this reason I can't understand why Spring isn't finding my annotations. As far as I'm aware the project structure is as it should be and everything is annotated properly. However when I visit the mapped endpoint http://localhost:8080/dashboard or http://localhost:8080/dashboard/, I see a 404 error.
I just created a new Spring Boot project using IntelliJ's built in Spring Initialiser, I selected Spring Web, and a few components for Postgres. Inside the project I can't find any additional .xml files for configuration. However, I did find:
DataSourceInitializerInvoker.java - which hasn't been edited
ConfigurationPropertiesAutoConfiguration.java - which hasn't been edited
Structure of my project is as follows:
com
+-abcde
+-appname
+-controllers
DashboardController.java
Application.java
Application.java:
package com.abcde.appname;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
DashboardController.java
package com.abcde.appname.controllers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
#Controller
#RequestMapping("/dashboard")
public class DashboardController {
#Autowired
public DashboardController() {
}
#GetMapping
public ModelAndView renderDashboard() {
return new ModelAndView("dashboard/index");
}
}
Alongside these files I also have the following,
application.properties
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=user
spring.datasource.driver-class-name=org.postgresql.Driver
spring.main.banner-mode=off
build.gradle
plugins {
id 'org.springframework.boot' version '2.3.3.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
}
group = 'com.abcde'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '14'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-freemarker'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.flywaydb:flyway-core'
runtimeOnly 'org.postgresql:postgresql'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
test {
useJUnitPlatform()
}
stacktrace
2020-09-09 23:24:46.053 INFO 57966 --- [ main] c.d.f.Application : Starting Application on OP-MacBook-Pro.local with PID 57966 (/Users/op/IdeaProjects/lalala/build/classes/java/main started by op in /Users/op/IdeaProjects/lalala)
2020-09-09 23:24:46.054 INFO 57966 --- [ main] c.d.f.Application : No active profile set, falling back to default profiles: default
2020-09-09 23:24:46.374 INFO 57966 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
2020-09-09 23:24:46.388 INFO 57966 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 10ms. Found 0 JPA repository interfaces.
2020-09-09 23:24:46.716 INFO 57966 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-09-09 23:24:46.720 INFO 57966 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-09-09 23:24:46.720 INFO 57966 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.37]
2020-09-09 23:24:46.775 INFO 57966 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-09-09 23:24:46.775 INFO 57966 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 700 ms
2020-09-09 23:24:46.832 INFO 57966 --- [ main] o.f.c.internal.license.VersionPrinter : Flyway Community Edition 6.4.4 by Redgate
2020-09-09 23:24:46.835 INFO 57966 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-09-09 23:24:46.872 INFO 57966 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-09-09 23:24:46.879 INFO 57966 --- [ main] o.f.c.internal.database.DatabaseFactory : Database: jdbc:postgresql://localhost:5432/postgres (PostgreSQL 12.3)
2020-09-09 23:24:46.901 INFO 57966 --- [ main] o.f.core.internal.command.DbValidate : Successfully validated 1 migration (execution time 00:00.011s)
2020-09-09 23:24:46.905 INFO 57966 --- [ main] o.f.core.internal.command.DbMigrate : Current version of schema "public": 10
2020-09-09 23:24:46.905 INFO 57966 --- [ main] o.f.core.internal.command.DbMigrate : Schema "public" is up to date. No migration necessary.
2020-09-09 23:24:46.960 INFO 57966 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-09-09 23:24:46.985 INFO 57966 --- [ task-1] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-09-09 23:24:47.000 WARN 57966 --- [ 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-09-09 23:24:47.010 INFO 57966 --- [ task-1] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.20.Final
2020-09-09 23:24:47.070 INFO 57966 --- [ task-1] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-09-09 23:24:47.122 INFO 57966 --- [ task-1] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL10Dialect
2020-09-09 23:24:47.253 INFO 57966 --- [ task-1] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-09-09 23:24:47.257 INFO 57966 --- [ task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-09-09 23:24:47.264 INFO 57966 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2020-09-09 23:24:47.265 INFO 57966 --- [ main] DeferredRepositoryInitializationListener : Triggering deferred initialization of Spring Data repositories…
2020-09-09 23:24:47.266 INFO 57966 --- [ main] DeferredRepositoryInitializationListener : Spring Data repositories initialized!
2020-09-09 23:24:47.273 INFO 57966 --- [ main] c.d.f.lalala : Started Application in 1.401 seconds (JVM running for 1.885)
2020-09-09 23:24:49.520 INFO 57966 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-09-09 23:24:49.520 INFO 57966 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-09-09 23:24:49.524 INFO 57966 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 4 ms
Any insight into this problem would be much appreciated. Many thanks
It's probably successfully invoking the renderDashboard() and is not finding "dashboard/index". You can verify that by debugging and setting a breakpoint or adding a log/System.out println statement. Does your index file exist and is it setup correctly?
I am trying to build my docker image for my spring boot application but keep encountering this error:
:: Spring Boot :: (v2.2.5.RELEASE)
2020-05-31 02:18:39.820 INFO 63 --- [ main] c.g.Apollo.ApolloApplicationTests : Starting ApolloApplicationTests on 4b284b60945e with PID 63 (started by root in /build)
2020-05-31 02:18:39.838 INFO 63 --- [ main] c.g.Apollo.ApolloApplicationTests : No active profile set, falling back to default profiles: default
2020-05-31 02:18:42.208 INFO 63 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-05-31 02:18:42.467 INFO 63 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 216ms. Found 3 JPA repository interfaces.
2020-05-31 02:18:44.902 INFO 63 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-05-31 02:18:46.575 ERROR 63 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization.
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174) ~[mysql-connector-java-8.0.20.jar:8.0.20]
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64) ~[mysql-connector-java-8.0.20.jar:8.0.20]
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836) ~[mysql-connector-java-8.0.20.jar:8.0.20]
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456) ~[mysql-connector-java-8.0.20.jar:8.0.20]
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246) ~[mysql-connector-java-8.0.20.jar:8.0.20]
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197) ~[mysql-connector-java-8.0.20.jar:8.0.20]
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[HikariCP-3.4.2.jar:na]
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:354) ~[HikariCP-3.4.2.jar:na]
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:202) ~[HikariCP-3.4.2.jar:na]
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:473) ~[HikariCP-3.4.2.jar:na]
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:554) ~[HikariCP-3.4.2.jar:na]
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) ~[HikariCP-3.4.2.jar:na]
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) ~[HikariCP-3.4.2.jar:na]
Terminal when successfully running in intellij:
:: Spring Boot :: (v2.2.5.RELEASE)
2020-05-31 01:04:39.322 INFO 19524 --- [ restartedMain] c.g.Apollo.ApolloApplication : Starting ApolloApplication on asd-PC with PID 19524 (C:\Projects\Apollo\target\classes started by asd in C:\Projects\Apollo)
2020-05-31 01:04:39.324 INFO 19524 --- [ restartedMain] c.g.Apollo.ApolloApplication : No active profile set, falling back to default profiles: default
2020-05-31 01:04:39.354 INFO 19524 --- [ restartedMain] o.s.b.devtools.restart.ChangeableUrls : The Class-Path manifest attribute in C:\Users\asd\.m2\repository\org\glassfish\jaxb\jaxb-runtime\2.3.2\jaxb-runtime-2.3.2.jar referenced one or more files that do not exist: file:/C:/Users/asd/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/jakarta.xml.bind-api-2.3.2.jar,file:/C:/Users/asd/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/txw2-2.3.2.jar,file:/C:/Users/asd/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/istack-commons-runtime-3.0.8.jar,file:/C:/Users/asd/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/stax-ex-1.8.1.jar,file:/C:/Users/asd/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/FastInfoset-1.2.16.jar,file:/C:/Users/asd/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/jakarta.activation-api-1.2.1.jar
2020-05-31 01:04:39.354 INFO 19524 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2020-05-31 01:04:39.354 INFO 19524 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2020-05-31 01:04:39.785 INFO 19524 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-05-31 01:04:39.846 INFO 19524 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 54ms. Found 3 JPA repository interfaces.
2020-05-31 01:04:40.214 INFO 19524 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-05-31 01:04:40.220 INFO 19524 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-05-31 01:04:40.221 INFO 19524 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.31]
2020-05-31 01:04:40.293 INFO 19524 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-05-31 01:04:40.293 INFO 19524 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 939 ms
2020-05-31 01:04:40.365 INFO 19524 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-05-31 01:04:40.702 INFO 19524 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-05-31 01:04:40.731 INFO 19524 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-05-31 01:04:40.800 INFO 19524 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.12.Final
2020-05-31 01:04:40.919 INFO 19524 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-05-31 01:04:41.006 INFO 19524 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
2020-05-31 01:04:41.407 INFO 19524 --- [ restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-05-31 01:04:41.413 INFO 19524 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-05-31 01:04:41.650 WARN 19524 --- [ restartedMain] 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-05-31 01:04:41.717 INFO 19524 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-05-31 01:04:41.967 INFO 19524 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2020-05-31 01:04:41.995 INFO 19524 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2020-05-31 01:04:41.997 INFO 19524 --- [ restartedMain] c.g.Apollo.ApolloApplication : Started ApolloApplication in 2.911 seconds (JVM running for 3.899)
My Dockerfile:
FROM maven:3.6.3-jdk-11-slim AS MAVEN_BUILD
COPY pom.xml /build/
COPY src /build/src/
WORKDIR /build/
RUN mvn package
FROM openjdk:11-jre-alpine
WORKDIR /app
COPY --from=MAVEN_BUILD /build/target/*.war /app/app.war
ENTRYPOINT ["java", "-jar", "app.war"]
My application.properties:
## GraphQL SPQR ##
server.port=8080
graphql.spqr.gui.enabled=true
graphql.spqr.http.endpoint=/graphql
graphql.spqr.ws.endpoint=/graphql
## Database Properties ##
spring.datasource.url=jdbc:mysql://localhost:3306/innodb
spring.datasource.username=root
spring.datasource.password=1234
My application works when I build and run the project in Intellij but not when I try and build my docker image. I am using MySQL and have just been connecting on localhost on port 3306.
The error message seems to indicate the issue is failing to connect to the database. From your settings, it appears that you are trying to connect to the DB using localhost:3306. That will not work when you are running the application in a container because docker creates its own network which is separate from you machine’s network. So, localhost in the container does not refer to your machine.
You need to instead setup a docker network that will allow your container to access the database in a specific IP address.
Here is an article with the specifics:
https://nickjanetakis.com/blog/docker-tip-35-connect-to-a-database-running-on-your-docker-host
Note that I have assumed from your post, that the DB is installed in your host machine. If it is not and the DB is running in its own container, the you need to create a docker network and attach both containers to that network.
I had the same issue and resolved it by changing localhost to the service name on which MySQL was running.
Below is my docker-compose and application.properties files
docker-compose.yml
version: '3.8'
services:
app:
container_name: tvms
build:
context: .
dockerfile: Dockerfile
tty: true
volumes:
- ../..:/workspaces:cached
ports:
- 8990:8990
networks:
- impaq
links:
- db:db
db:
image: percona:8.0
privileged: true
restart: always
container_name: standalone-mysql
environment:
MYSQL_ROOT_PASSWORD: ****
volumes:
- perconadata:/var/lib/mysql
ports:
- 3306:3306
networks:
- impaq
networks:
impaq:
volumes:
perconadata:
application.propeties
#datasource
spring.datasource.url=jdbc:mysql://db:3306/db_name
spring.datasource.username=root
spring.datasource.password=*****
For me below solution worked
change your datasource url from
This:
spring.datasource.url=jdbc:mysql://localhost:3306/innodb
To:
spring.datasource.url=jdbc:mysql://localhost:3306/innodb?useSSL=false
So I've been trying to do the example from spring's official guide on connecting Spring with MySQL (https://spring.io/guides/gs/accessing-data-mysql/)
I didn't follow it 100% since I'm using STS for my overall project. The thing is when I use POSTMAN or just my browser to send data
such as :
localhost:8000/demo/add?name=First&email=someemail#someemailprovider.com
I get the error not found.
The java code is the same as in the guide . My application.properties is this:
server.port=8000
spring.jpa.hibernate.ddl-auto=create
spring.datasource.url=jdbc:mysql://localhost:3306/db_example
spring.datasource.username=springuser
spring.datasource.password=ThePassword
and my pom.xml is this
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>dbDemo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>dbDemo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<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-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-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
The answer from my browser is:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing
this as a fallback.
Tue Jul 10 21:15:52 EEST 2018
There was an unexpected error (type=Not Found, status=404).
No message available
And from postman :
{
"timestamp": "2018-07-10T18:08:28.208+0000",
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/demo/add"
}
The log from spring's console is :
:: Spring Boot :: (v2.0.3.RELEASE)
2018-07-10 20:32:36.453 INFO 7815 --- [ main] com.example.demo.DbDemoApplication : Starting DbDemoApplication on max-kans with PID 7815 (/home/max/Desktop/Fetina/Earino/projectTL/softEngine/dbDemo/target/classes started by max in /home/max/Desktop/Fetina/Earino/projectTL/softEngine/dbDemo)
2018-07-10 20:32:36.496 INFO 7815 --- [ main] com.example.demo.DbDemoApplication : No active profile set, falling back to default profiles: default
2018-07-10 20:32:36.742 INFO 7815 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#2aa5fe93: startup date [Tue Jul 10 20:32:36 EEST 2018]; root of context hierarchy
2018-07-10 20:32:41.650 INFO 7815 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$5ab04215] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-10 20:32:42.775 INFO 7815 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8000 (http)
2018-07-10 20:32:43.344 INFO 7815 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-07-10 20:32:43.344 INFO 7815 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.31
2018-07-10 20:32:44.326 INFO 7815 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
2018-07-10 20:32:47.580 INFO 7815 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-07-10 20:32:47.581 INFO 7815 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 10868 ms
2018-07-10 20:32:48.187 INFO 7815 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-07-10 20:32:48.192 INFO 7815 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-07-10 20:32:48.193 INFO 7815 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-07-10 20:32:48.193 INFO 7815 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-07-10 20:32:48.193 INFO 7815 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-07-10 20:32:50.090 INFO 7815 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2018-07-10 20:32:54.757 INFO 7815 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2018-07-10 20:32:55.307 INFO 7815 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-07-10 20:32:55.640 INFO 7815 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2018-07-10 20:32:58.848 INFO 7815 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.2.17.Final}
2018-07-10 20:32:59.125 INFO 7815 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2018-07-10 20:33:00.513 INFO 7815 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2018-07-10 20:33:02.175 INFO 7815 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2018-07-10 20:33:03.329 INFO 7815 --- [ main] o.h.t.schema.internal.SchemaCreatorImpl : HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl#7a8406c2'
2018-07-10 20:33:03.331 INFO 7815 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-07-10 20:33:06.623 INFO 7815 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-10 20:33:08.065 INFO 7815 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#2aa5fe93: startup date [Tue Jul 10 20:32:36 EEST 2018]; root of context hierarchy
2018-07-10 20:33:08.206 WARN 7815 --- [ 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
2018-07-10 20:33:08.322 INFO 7815 --- [ 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.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-07-10 20:33:08.324 INFO 7815 --- [ 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.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-07-10 20:33:08.368 INFO 7815 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-10 20:33:08.368 INFO 7815 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-10 20:33:09.610 INFO 7815 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-07-10 20:33:09.613 INFO 7815 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'dataSource' has been autodetected for JMX exposure
2018-07-10 20:33:09.622 INFO 7815 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource]
2018-07-10 20:33:10.003 INFO 7815 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8000 (http) with context path ''
2018-07-10 20:33:10.154 INFO 7815 --- [ main] com.example.demo.DbDemoApplication : Started DbDemoApplication in 35.885 seconds (JVM running for 39.933)
2018-07-10 20:34:07.354 INFO 7815 --- [nio-8000-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2018-07-10 20:34:07.354 INFO 7815 --- [nio-8000-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2018-07-10 20:34:07.962 INFO 7815 --- [nio-8000-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 608 ms
My controller is pretty much identical to the one from spring's guide :
package hello;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import hello.User;
import hello.UserRepository;
#Controller // This means that this class is a Controller
#RequestMapping(path="/demo")
// This means URL's start with /demo (after Application path)
public class UserController {
#Autowired
// This means to get the bean called userRepository
// Which is auto-generated by Spring, we will use it to handle the data
private UserRepository userRepository;
#GetMapping(path="/add") // Map ONLY GET Requests
public #ResponseBody String addNewUser(#RequestParam String name,
#RequestParam String email) {
// #ResponseBody means the returned String is the response,
// not a view name
User n = new User();
n.setName(name);
n.setEmail(email);
userRepository.save(n);
return "Saved";
}
#GetMapping(path="/all")
public #ResponseBody Iterable<User> getAllUsers() {
// This returns a JSON or XML with the users
return userRepository.findAll();
}
}
Your #SpringBootApplication class is in the package com.example.demo (according to the startup log), but your #Controller is in package hello. By default, Spring Boot won't auto-discover Spring classes that are outside the package the #SpringBootApplication class is in. Either move the UserController somewhere under the com.example.demo, or add #ComponentScan annotation targeting your hello package to the main Spring Boot app class.
I'm using spring boot 1.5.4, i'm following a tutorial where it shows that just by adding h2-console to the localhost:8080/ url you can access the console. But when i do that i have a 404 Whitelabel error.
These are the dependencies
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--WebJars-->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.5</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.2.1</version>
</dependency>
<!--jpa and database-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
And this is the spring boot console log
2017-07-19 01:35:25.222 INFO 8644 --- [ main] c.e.s.SpringBootTest00Application : Starting SpringBootTest00Application on DESKTOP-K8Q0B2R with PID 8644 (started by Talon in C:\Users\Talon\Desktop\java netbeans\01\springBootTest00)
2017-07-19 01:35:25.225 INFO 8644 --- [ main] c.e.s.SpringBootTest00Application : No active profile set, falling back to default profiles: default
2017-07-19 01:35:25.544 INFO 8644 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#37574691: startup date [Wed Jul 19 01:35:25 CEST 2017]; root of context hierarchy
2017-07-19 01:35:27.236 INFO 8644 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-07-19 01:35:27.248 INFO 8644 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2017-07-19 01:35:27.249 INFO 8644 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.15
2017-07-19 01:35:27.378 INFO 8644 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-07-19 01:35:27.378 INFO 8644 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1838 ms
2017-07-19 01:35:27.578 INFO 8644 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-07-19 01:35:27.582 INFO 8644 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-07-19 01:35:27.584 INFO 8644 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-07-19 01:35:27.584 INFO 8644 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-07-19 01:35:27.584 INFO 8644 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-07-19 01:35:28.020 INFO 8644 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2017-07-19 01:35:28.037 INFO 8644 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2017-07-19 01:35:28.122 INFO 8644 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final}
2017-07-19 01:35:28.123 INFO 8644 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2017-07-19 01:35:28.180 INFO 8644 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2017-07-19 01:35:28.219 INFO 8644 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2017-07-19 01:35:28.321 INFO 8644 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2017-07-19 01:35:28.742 INFO 8644 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
2017-07-19 01:35:28.757 INFO 8644 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
2017-07-19 01:35:28.809 INFO 8644 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2017-07-19 01:35:29.119 INFO 8644 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#37574691: startup date [Wed Jul 19 01:35:25 CEST 2017]; root of context hierarchy
2017-07-19 01:35:29.203 INFO 8644 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto public java.lang.String com.example.springBootTest00.controllers.IndexController.index()
2017-07-19 01:35:29.205 INFO 8644 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/product],methods=[POST]}" onto public java.lang.String com.example.springBootTest00.controllers.ProductController.saveOrUpdateProduct(com.example.springBootTest00.domain.Product)
2017-07-19 01:35:29.206 INFO 8644 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/product/edit/{id}]}" onto public java.lang.String com.example.springBootTest00.controllers.ProductController.edit(java.lang.Integer,org.springframework.ui.Model)
2017-07-19 01:35:29.206 INFO 8644 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/product/new]}" onto public java.lang.String com.example.springBootTest00.controllers.ProductController.newProduct(org.springframework.ui.Model)
2017-07-19 01:35:29.206 INFO 8644 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/product/delete/{id}]}" onto public java.lang.String com.example.springBootTest00.controllers.ProductController.deleteProduct(java.lang.Integer,org.springframework.ui.Model)
2017-07-19 01:35:29.206 INFO 8644 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/products]}" onto public java.lang.String com.example.springBootTest00.controllers.ProductController.listProducts(org.springframework.ui.Model)
2017-07-19 01:35:29.206 INFO 8644 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/product/{id}]}" onto public java.lang.String com.example.springBootTest00.controllers.ProductController.getProduct(java.lang.Integer,org.springframework.ui.Model)
2017-07-19 01:35:29.209 INFO 8644 --- [ 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-07-19 01:35:29.209 INFO 8644 --- [ 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-07-19 01:35:29.243 INFO 8644 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-07-19 01:35:29.244 INFO 8644 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-07-19 01:35:29.284 INFO 8644 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-07-19 01:35:29.920 INFO 8644 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-07-19 01:35:29.983 INFO 8644 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-07-19 01:35:29.987 INFO 8644 --- [ main] c.e.s.SpringBootTest00Application : Started SpringBootTest00Application in 5.052 seconds (JVM running for 5.401)
I have some classes with #Service / #Controller working properly and all the requests are mapped to url strings other than h2-console. Should i import something else in the pom or configure something in application.properties ?
Writing in simple Steps:
In Application.properties file include
spring.h2.console.path=/h2
spring.h2.console.enabled=true
And in pom.xml Include devtools dependency
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
re-package and open http://localhost:[port]/h2 you are all set
other properties you have to include is
spring.datasource.url=jdbc:h2:file:~/h2db
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
the file h2db will store in userprofile folder of windows
for example : C:\Users\[profile]