I've created a new project with Spring Initializr and I configured connection with SSMS database:
spring.datasource.url=jdbc:sqlserver://xxxxxxxx;databaseName=yyyyyy
spring.datasource.username=
spring.datasource.password=
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.show-sql=true
spring.jpa.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
spring.jpa.hibernate.ddl-auto=update
I also created a test model class to check everything works fine:
#Getter
#Setter
#AllArgsConstructor
#NoArgsConstructor
#EqualsAndHashCode(callSuper = false)
#ToString
#Builder
#Entity
#Table(name = "USR", schema = "dbo")
public class User {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private Integer usrId;
}
This is my console output:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.4.1)
2020-12-21 21:15:06.574 INFO 22192 --- [ restartedMain] c.e.employees.EmployeesApplication : Starting EmployeesApplication using Java 11.0.8 on DESKTOP-OEEHFPE with PID 22192 (C:\Alina\employees\target\classes started by olaru in C:\Alina\employees)
2020-12-21 21:15:06.577 INFO 22192 --- [ restartedMain] c.e.employees.EmployeesApplication : The following profiles are active: #spring.profiles.active#
2020-12-21 21:15:06.637 INFO 22192 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2020-12-21 21:15:07.211 INFO 22192 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-12-21 21:15:07.226 INFO 22192 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 5 ms. Found 0 JPA repository interfaces.
2020-12-21 21:15:07.646 INFO 22192 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-12-21 21:15:07.695 INFO 22192 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.25.Final
2020-12-21 21:15:07.798 INFO 22192 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2020-12-21 21:15:07.902 INFO 22192 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-12-21 21:15:08.200 INFO 22192 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-12-21 21:15:08.220 INFO 22192 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.SQLServer2012Dialect
2020-12-21 21:15:08.710 INFO 22192 --- [ restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-12-21 21:15:08.721 INFO 22192 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-12-21 21:15:08.761 INFO 22192 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2020-12-21 21:15:08.873 INFO 22192 --- [ restartedMain] c.e.employees.EmployeesApplication : Started EmployeesApplication in 2.792 seconds (JVM running for 4.218)
2020-12-21 21:15:08.885 INFO 22192 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-12-21 21:15:08.892 INFO 22192 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2020-12-21 21:15:08.898 INFO 22192 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
Process finished with exit code 0
I don't see any error in the console, but the table is not created. Please let me know if you have any idea what's wrong.
Did you add the required dependencies?
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>
You also need to enable entity scan, in case you didn't:
#Configuration
#EntityScan(basePackages = {"my.package"})
#EnableJpaRepositories(basePackages = {"my.package"})
Basically your first three properties would be enough, but the others shouldn't harm.
spring.datasource.url=jdbc:sqlserver://localhost;databaseName=my-app
spring.datasource.username=sa
spring.datasource.password=<<YOUR_PASSWORD>>
If you like create a Spring Boot app for MS SQL at https://bootify.io to see the full configuration.
Related
i have a application.yml to auto-creation some table:
## JDBC part
spring:
config:
activate:
on-profile: local
enabled: true
datasource:
url: jdbc:mysql://localhost:3306/kazi?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
driver-class-name: com.mysql.cj.jdbc.Driver
username: emo
password: 123qwe
jpa:
show-sql: true
database-platform: org.hibernate.dialect.MySQL8Dialect
hibernate:
ddl-auto: update
liquibase:
change-log: classpath:liquibase/changelog.xml
#spring.jpa.properties.hibernate.hbm2ddl.import_files=import.sql
main class:
#EnableAutoConfiguration(exclude = DataSourceAutoConfiguration.class)
#SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Log
/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/bin/java -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=57211:/Applications/IntelliJ IDEA.app/Contents/bin -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dfile.encoding=UTF-8 -classpath /Users/emoleumassi/Documents/Projects/me/kazi/kazi-core/target/classes:/Users/emoleumassi/.m2/repository/org/liquibase/liquibase-core/4.5.0/liquibase-core-4.5.0.jar:/Users/emoleumassi/.m2/repository/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar:/Users/emoleumassi/.m2/repository/javax/activation/javax.activation-api/1.2.0/javax.activation-api-1.2.0.jar:/Users/emoleumassi/.m2/repository/org/liquibase/liquibase-maven-plugin/3.8.2/liquibase-maven-plugin-3.8.2.jar:/Users/emoleumassi/.m2/repository/org/apache/maven/maven-plugin-api/2.0/maven-plugin-api-2.0.jar:/Users/emoleumassi/.m2/repository/org/apache/maven/maven-project/2.0/maven-project-2.0.jar:/Users/emoleumassi/.m2/repository/org/apache/maven/maven-profile/2.0/maven-profile-2.0.jar:/Users/emoleumassi/.m2/repository/org/apache/maven/maven-model/2.0/maven-model-2.0.jar:/Users/emoleumassi/.m2/repository/org/apache/maven/maven-artifact-manager/2.0/maven-artifact-manager-2.0.jar:/Users/emoleumassi/.m2/repository/org/apache/maven/maven-repository-metadata/2.0/maven-repository-metadata-2.0.jar:/Users/emoleumassi/.m2/repository/org/apache/maven/wagon/wagon-provider-api/1.0-alpha-5/wagon-provider-api-1.0-alpha-5.jar:/Users/emoleumassi/.m2/repository/org/codehaus/plexus/plexus-utils/1.0.4/plexus-utils-1.0.4.jar:/Users/emoleumassi/.m2/repository/org/apache/maven/maven-artifact/2.0/maven-artifact-2.0.jar:/Users/emoleumassi/.m2/repository/org/codehaus/plexus/plexus-container-default/1.0-alpha-8/plexus-container-default-1.0-alpha-8.jar:/Users/emoleumassi/.m2/repository/junit/junit/4.13.2/junit-4.13.2.jar:/Users/emoleumassi/.m2/repository/org/hamcrest/hamcrest-core/2.2/hamcrest-core-2.2.jar:/Users/emoleumassi/.m2/repository/classworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar:/Users/emoleumassi/.m2/repository/org/slf4j/slf4j-api/1.7.32/slf4j-api-1.7.32.jar:/Users/emoleumassi/.m2/repository/ch/qos/logback/logback-classic/1.2.9/logback-classic-1.2.9.jar:/Users/emoleumassi/.m2/repository/ch/qos/logback/logback-core/1.2.9/logback-core-1.2.9.jar:/Users/emoleumassi/.m2/repository/com/fasterxml/jackson/module/jackson-module-jaxb-annotations/2.13.1/jackson-module-jaxb-annotations-2.13.1.jar:/Users/emoleumassi/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.13.1/jackson-annotations-2.13.1.jar:/Users/emoleumassi/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.13.1/jackson-core-2.13.1.jar:/Users/emoleumassi/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.13.1/jackson-databind-2.13.1.jar:/Users/emoleumassi/.m2/repository/jakarta/xml/bind/jakarta.xml.bind-api/2.3.3/jakarta.xml.bind-api-2.3.3.jar:/Users/emoleumassi/.m2/repository/jakarta/activation/jakarta.activation-api/1.2.2/jakarta.activation-api-1.2.2.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-starter-data-jpa/2.6.2/spring-boot-starter-data-jpa-2.6.2.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-starter-aop/2.6.2/spring-boot-starter-aop-2.6.2.jar:/Users/emoleumassi/.m2/repository/org/aspectj/aspectjweaver/1.9.7/aspectjweaver-1.9.7.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-starter-jdbc/2.6.2/spring-boot-starter-jdbc-2.6.2.jar:/Users/emoleumassi/.m2/repository/com/zaxxer/HikariCP/4.0.3/HikariCP-4.0.3.jar:/Users/emoleumassi/.m2/repository/org/springframework/spring-jdbc/5.3.14/spring-jdbc-5.3.14.jar:/Users/emoleumassi/.m2/repository/jakarta/transaction/jakarta.transaction-api/1.3.3/jakarta.transaction-api-1.3.3.jar:/Users/emoleumassi/.m2/repository/jakarta/persistence/jakarta.persistence-api/2.2.3/jakarta.persistence-api-2.2.3.jar:/Users/emoleumassi/.m2/repository/org/hibernate/hibernate-core/5.6.3.Final/hibernate-core-5.6.3.Final.jar:/Users/emoleumassi/.m2/repository/org/jboss/logging/jboss-logging/3.4.2.Final/jboss-logging-3.4.2.Final.jar:/Users/emoleumassi/.m2/repository/net/bytebuddy/byte-buddy/1.11.22/byte-buddy-1.11.22.jar:/Users/emoleumassi/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar:/Users/emoleumassi/.m2/repository/org/jboss/jandex/2.2.3.Final/jandex-2.2.3.Final.jar:/Users/emoleumassi/.m2/repository/com/fasterxml/classmate/1.5.1/classmate-1.5.1.jar:/Users/emoleumassi/.m2/repository/org/hibernate/common/hibernate-commons-annotations/5.1.2.Final/hibernate-commons-annotations-5.1.2.Final.jar:/Users/emoleumassi/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.5/jaxb-runtime-2.3.5.jar:/Users/emoleumassi/.m2/repository/org/glassfish/jaxb/txw2/2.3.5/txw2-2.3.5.jar:/Users/emoleumassi/.m2/repository/com/sun/istack/istack-commons-runtime/3.0.12/istack-commons-runtime-3.0.12.jar:/Users/emoleumassi/.m2/repository/com/sun/activation/jakarta.activation/1.2.2/jakarta.activation-1.2.2.jar:/Users/emoleumassi/.m2/repository/org/springframework/data/spring-data-jpa/2.6.0/spring-data-jpa-2.6.0.jar:/Users/emoleumassi/.m2/repository/org/springframework/data/spring-data-commons/2.6.0/spring-data-commons-2.6.0.jar:/Users/emoleumassi/.m2/repository/org/springframework/spring-orm/5.3.14/spring-orm-5.3.14.jar:/Users/emoleumassi/.m2/repository/org/springframework/spring-context/5.3.14/spring-context-5.3.14.jar:/Users/emoleumassi/.m2/repository/org/springframework/spring-tx/5.3.14/spring-tx-5.3.14.jar:/Users/emoleumassi/.m2/repository/org/springframework/spring-beans/5.3.14/spring-beans-5.3.14.jar:/Users/emoleumassi/.m2/repository/org/springframework/spring-aspects/5.3.14/spring-aspects-5.3.14.jar:/Users/emoleumassi/.m2/repository/mysql/mysql-connector-java/8.0.27/mysql-connector-java-8.0.27.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-starter/2.6.2/spring-boot-starter-2.6.2.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.6.2/spring-boot-starter-logging-2.6.2.jar:/Users/emoleumassi/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.17.0/log4j-to-slf4j-2.17.0.jar:/Users/emoleumassi/.m2/repository/org/apache/logging/log4j/log4j-api/2.17.0/log4j-api-2.17.0.jar:/Users/emoleumassi/.m2/repository/org/slf4j/jul-to-slf4j/1.7.32/jul-to-slf4j-1.7.32.jar:/Users/emoleumassi/.m2/repository/org/yaml/snakeyaml/1.29/snakeyaml-1.29.jar:/Users/emoleumassi/.m2/repository/org/hamcrest/hamcrest/2.2/hamcrest-2.2.jar:/Users/emoleumassi/.m2/repository/org/springframework/spring-core/5.3.14/spring-core-5.3.14.jar:/Users/emoleumassi/.m2/repository/org/springframework/spring-jcl/5.3.14/spring-jcl-5.3.14.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-starter-security/2.6.2/spring-boot-starter-security-2.6.2.jar:/Users/emoleumassi/.m2/repository/org/springframework/spring-aop/5.3.14/spring-aop-5.3.14.jar:/Users/emoleumassi/.m2/repository/org/springframework/security/spring-security-config/5.6.1/spring-security-config-5.6.1.jar:/Users/emoleumassi/.m2/repository/org/springframework/security/spring-security-core/5.6.1/spring-security-core-5.6.1.jar:/Users/emoleumassi/.m2/repository/org/springframework/security/spring-security-crypto/5.6.1/spring-security-crypto-5.6.1.jar:/Users/emoleumassi/.m2/repository/org/springframework/security/spring-security-web/5.6.1/spring-security-web-5.6.1.jar:/Users/emoleumassi/.m2/repository/org/springframework/spring-expression/5.3.14/spring-expression-5.3.14.jar:/Users/emoleumassi/.m2/repository/org/springframework/spring-web/5.3.14/spring-web-5.3.14.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/2.6.2/spring-boot-starter-tomcat-2.6.2.jar:/Users/emoleumassi/.m2/repository/jakarta/annotation/jakarta.annotation-api/1.3.5/jakarta.annotation-api-1.3.5.jar:/Users/emoleumassi/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.56/tomcat-embed-core-9.0.56.jar:/Users/emoleumassi/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/9.0.56/tomcat-embed-el-9.0.56.jar:/Users/emoleumassi/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/9.0.56/tomcat-embed-websocket-9.0.56.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-devtools/2.6.2/spring-boot-devtools-2.6.2.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot/2.6.2/spring-boot-2.6.2.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.6.2/spring-boot-autoconfigure-2.6.2.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-starter-actuator/2.6.2/spring-boot-starter-actuator-2.6.2.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-actuator-autoconfigure/2.6.2/spring-boot-actuator-autoconfigure-2.6.2.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-actuator/2.6.2/spring-boot-actuator-2.6.2.jar:/Users/emoleumassi/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.13.1/jackson-datatype-jsr310-2.13.1.jar:/Users/emoleumassi/.m2/repository/io/micrometer/micrometer-core/1.8.1/micrometer-core-1.8.1.jar:/Users/emoleumassi/.m2/repository/org/hdrhistogram/HdrHistogram/2.1.12/HdrHistogram-2.1.12.jar:/Users/emoleumassi/.m2/repository/org/latencyutils/LatencyUtils/2.0.3/LatencyUtils-2.0.3.jar:/Users/emoleumassi/.m2/repository/org/projectlombok/lombok/1.18.16/lombok-1.18.16.jar:/Users/emoleumassi/.m2/repository/org/projectlombok/lombok-mapstruct-binding/0.2.0/lombok-mapstruct-binding-0.2.0.jar com.kazi.Application
19:21:19.040 [Thread-0] DEBUG org.springframework.boot.devtools.restart.classloader.RestartClassLoader - Created RestartClassLoader org.springframework.boot.devtools.restart.classloader.RestartClassLoader#32d703c9
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.6.2)
2022-01-24 19:21:19.677 INFO 28392 --- [ restartedMain] com.kazi.Application : Starting Application using Java 11.0.11 on FVFFF491Q05N.fritz.box with PID 28392 (/kazi/kazi-core/target/classes started by in //kazi)
2022-01-24 19:21:19.678 INFO 28392 --- [ restartedMain] com.kazi.Application : No active profile set, falling back to default profiles: default
2022-01-24 19:21:19.743 INFO 28392 --- [ restartedMain] o.s.b.devtools.restart.ChangeableUrls : The Class-Path manifest attribute in //.m2/repository/org/liquibase/liquibase-core/4.5.0/liquibase-core-4.5.0.jar referenced one or more files that do not exist: file://.m2/repository/org/liquibase/liquibase-core/4.5.0/snakeyaml-1.27.jar
2022-01-24 19:21:19.745 INFO 28392 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2022-01-24 19:21:19.745 INFO 28392 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2022-01-24 19:21:21.125 INFO 28392 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-01-24 19:21:21.132 INFO 28392 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-01-24 19:21:21.132 INFO 28392 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.56]
2022-01-24 19:21:21.208 INFO 28392 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-01-24 19:21:21.209 INFO 28392 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1464 ms
2022-01-24 19:21:21.656 INFO 28392 --- [ restartedMain] .s.s.UserDetailsServiceAutoConfiguration :
Using generated security password: 6b57bd8f-9f75-40b5-8805-d33182a6782f
2022-01-24 19:21:21.719 INFO 28392 --- [ restartedMain] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#585f2fd, org.springframework.security.web.context.SecurityContextPersistenceFilter#217e757f, org.springframework.security.web.header.HeaderWriterFilter#54ef1e31, org.springframework.security.web.csrf.CsrfFilter#1323ecfd, org.springframework.security.web.authentication.logout.LogoutFilter#50c74237, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#31cfd78a, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter#175a6ba7, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter#74ce9809, org.springframework.security.web.authentication.www.BasicAuthenticationFilter#1143ca59, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#4de8bf20, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#272d7d98, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#7bd095cb, org.springframework.security.web.session.SessionManagementFilter#7d64f793, org.springframework.security.web.access.ExceptionTranslationFilter#8fd5915, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#53681a29]
2022-01-24 19:21:21.782 INFO 28392 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2022-01-24 19:21:21.835 INFO 28392 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2022-01-24 19:21:21.856 INFO 28392 --- [ restartedMain] com.kazi.Application : Started Application in 2.798 seconds (JVM running for 3.673)
The application start successfully but the tables haven't created. I tried it with ddl-auto: create und have the same problem.
I think the application.yml isn't load.
The location:
I think no Datasource in this app.
#EnableAutoConfiguration(exclude = DataSourceAutoConfiguration.class)
try this
#EnableAutoConfiguration
I/O error on POST request for "http://localhost:9411/api/v2/spans": Connect timed out; nested exception is java.net.SocketTimeoutException: Connect timed out
2021-11-24 10:17:30.642 INFO [,,,] 7872 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.2.RELEASE)
2021-11-24 10:17:31.942 INFO [service,,,] 7872 --- [ restartedMain] ServiceApplication : No active profile set, falling back to default profiles: default
2021-11-24 10:17:35.956 INFO [service,,,] 7872 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
2021-11-24 10:17:36.883 INFO [service,,,] 7872 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 901ms. Found 27 JPA repository interfaces.
2021-11-24 10:17:38.737 INFO [service,,,] 7872 --- [ restartedMain] o.s.cloud.context.scope.GenericScope : BeanFactory id=f090e4ad-27c8-34fa-89ba-eeeccacd1fd9
2021-11-24 10:17:42.104 INFO [service,,,] 7872 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 9194 (http)
2021-11-24 10:17:42.149 INFO [service,,,] 7872 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-11-24 10:17:42.150 INFO [service,,,] 7872 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.37]
2021-11-24 10:17:42.661 INFO [service,,,] 7872 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-11-24 10:17:42.662 INFO [service,,,] 7872 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 10646 ms
2021-11-24 10:17:43.074 INFO [service,,,] 7872 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-11-24 10:17:43.494 INFO [service,,,] 7872 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-11-24 10:17:43.517 INFO [service,,,] 7872 --- [ restartedMain] o.s.b.a.h2.H2ConsoleAutoConfiguration : H2 console available at '/h2-console'. Database available at 'jdbc:postgresql://localhost:5432/codeis'
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils (file:/C:/Users/Hp/.m2/repository/org/springframework/spring-core/5.2.8.RELEASE/spring-core-5.2.8.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2021-11-24 10:17:46.238 WARN [school-erp-service,,,] 7872 --- [ restartedMain] o.s.c.s.zipkin2.ZipkinAutoConfiguration : Check result of the [org.springframework.cloud.sleuth.zipkin2.sender.RestTemplateSender#41a2805a] contains an error [CheckResult{ok=false, error=org.springframework.web.client.ResourceAccessException: I/O error on POST request for "http://localhost:9411/api/v2/spans": Connect timed out; nested exception is java.net.SocketTimeoutException: Connect timed out}]
What mistake I make?
I am not using the Zipkin server.
Why throw such type of error how to resolve it?
I am using zuul API gateway.
Check your build dependency tree, there must be an entry for spring-cloud-starter-sleuth. In case you are planning not to use it, then remove it.
The firewall is not turned off
$ systemctl stop firewalld
I need to deploy SCDF 2.8.0 version in OKD. I also made changes to SCDF Code to add the Oracle Driver dependency. When I scale up the POD after adding all configurations of SCDF as given in the documentation I get the below error. I tried changing the port but It's of no use.
There are other Rest applications deployed in the same environment and they have no issues in exposing the service via the port 80 or 81. Kindly let me know your inputs.
____ ____ _ __
/ ___| _ __ _ __(_)_ __ __ _ / ___| | ___ _ _ __| |
\___ \| '_ \| '__| | '_ \ / _` | | | | |/ _ \| | | |/ _` |
___) | |_) | | | | | | | (_| | | |___| | (_) | |_| | (_| |
|____/| .__/|_| |_|_| |_|\__, | \____|_|\___/ \__,_|\__,_|
____ |_| _ __|___/ __________
| _ \ __ _| |_ __ _ | ___| | _____ __ \ \ \ \ \ \
| | | |/ _` | __/ _` | | |_ | |/ _ \ \ /\ / / \ \ \ \ \ \
| |_| | (_| | || (_| | | _| | | (_) \ V V / / / / / / /
|____/ \__,_|\__\__,_| |_| |_|\___/ \_/\_/ /_/_/_/_/_/
Spring Cloud Data Flow Server (v2.8.0)
2021-06-22 12:24:49.231 INFO 1 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-configmap.scdf-server.devfac-capella-batches'}]
2021-06-22 12:24:49.258 INFO 1 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-oracle-root-username'}, BootstrapPropertySource {name='bootstrapProperties-oracle-root-url'}, BootstrapPropertySource {name='bootstrapProperties-oracle-root-password'}, BootstrapPropertySource {name='bootstrapProperties-secrets.spring-cloud-dataflow-server.devfac-capella-batches'}]
2021-06-22 12:24:49.426 INFO 1 --- [ main] o.s.c.d.s.s.DataFlowServerApplication : The following profiles are active: dev,kubernetes
2021-06-22 12:24:53.337 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2021-06-22 12:24:53.338 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Map repositories in DEFAULT mode.
2021-06-22 12:24:53.924 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 555 ms. Found 1 Map repository interfaces.
2021-06-22 12:24:55.329 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2021-06-22 12:24:55.333 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-06-22 12:24:55.351 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 2 ms. Found 0 JPA repository interfaces.
2021-06-22 12:24:56.222 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2021-06-22 12:24:56.222 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-06-22 12:24:56.456 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 233 ms. Found 5 JPA repository interfaces.
2021-06-22 12:24:57.121 INFO 1 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=46e2ec48-3213-3e84-8b1a-af720b97c983
2021-06-22 12:24:59.309 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 81 (http)
2021-06-22 12:24:59.331 INFO 1 --- [ main] o.a.coyote.http11.Http11NioProtocol : Initializing ProtocolHandler ["http-nio-81"]
2021-06-22 12:24:59.332 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-06-22 12:24:59.332 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.45]
2021-06-22 12:24:59.608 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-06-22 12:25:01.547 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-06-22 12:25:02.648 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-06-22 12:25:03.020 INFO 1 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-06-22 12:25:03.637 INFO 1 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.30.Final
2021-06-22 12:25:04.536 INFO 1 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-06-22 12:25:05.046 INFO 1 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.Oracle12cDialect
2021-06-22 12:25:06.918 INFO 1 --- [ main] o.h.validator.internal.util.Version : HV000001: Hibernate Validator 6.1.7.Final
2021-06-22 12:25:08.958 INFO 1 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-06-22 12:25:09.011 INFO 1 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-06-22 12:25:09.933 INFO 1 --- [ main] d.c.r.ContainerRegistryAutoConfiguration : Final Registry Configurations: {registry-1.docker.io=ContainerRegistryConfiguration{registryHost='registry-1.docker.io', user='null', secret='****'', authorizationType=dockeroauth2, manifestMediaType='application/vnd.docker.distribution.manifest.v2+json', disableSslVerification='false', useHttpProxy='false', extra={registryAuthUri=https://auth.docker.io/token?service=registry.docker.io&scope=repository:{repository}:pull&offline_token=1&client_id=shell}}}
2021-06-22 12:25:12.908 WARN 1 --- [ main] .s.c.d.s.s.i.TaskConfigurationProperties : org.springframework.cloud.dataflow.server.service.impl.TaskConfigurationProperties.setComposedTaskRunnerUri is deprecated. Please use org.springframework.cloud.dataflow.server.service.impl.ComposedTaskRunnerConfigurationProperties.setUri
2021-06-22 12:25:13.826 INFO 1 --- [ main] o.s.b.c.r.s.JobRepositoryFactoryBean : No database type set, using meta data indicating: ORACLE
2021-06-22 12:25:14.041 INFO 1 --- [ main] o.s.c.d.s.b.SimpleJobServiceFactoryBean : No database type set, using meta data indicating: ORACLE
2021-06-22 12:25:14.730 WARN 1 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2021-06-22 12:25:15.148 INFO 1 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2021-06-22 12:25:18.118 INFO 1 --- [ main] .s.c.DataFlowControllerAutoConfiguration : Skipper URI [http://localhost:7577/api]
2021-06-22 12:25:18.942 INFO 1 --- [ main] o.a.coyote.http11.Http11NioProtocol : Starting ProtocolHandler ["http-nio-81"]
2021-06-22 12:25:18.951 WARN 1 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
2021-06-22 12:25:19.030 INFO 1 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2021-06-22 12:25:19.041 INFO 1 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2021-06-22 12:25:19.045 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2021-06-22 12:25:19.144 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2021-06-22 12:25:19.147 INFO 1 --- [ main] o.a.coyote.http11.Http11NioProtocol : Pausing ProtocolHandler ["http-nio-81"]
2021-06-22 12:25:19.148 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2021-06-22 12:25:19.154 INFO 1 --- [ main] o.a.coyote.http11.Http11NioProtocol : Stopping ProtocolHandler ["http-nio-81"]
2021-06-22 12:25:19.155 INFO 1 --- [ main] o.a.coyote.http11.Http11NioProtocol : Destroying ProtocolHandler ["http-nio-81"]
2021-06-22 12:25:19.746 ERROR 1 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181)
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356)
at java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155)
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:782)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:774)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:339)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1340)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329)
at org.springframework.cloud.dataflow.server.single.DataFlowServerApplication.main(DataFlowServerApplication.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:229)
at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:43)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178)
... 23 common frames omitted
Caused by: java.lang.IllegalArgumentException: standardService.connector.startFailed
at org.apache.catalina.core.StandardService.addConnector(StandardService.java:243)
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:282)
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:213)
... 25 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Protocol handler start failed
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1074)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.addConnector(StandardService.java:239)
... 27 common frames omitted
Caused by: java.net.SocketException: Permission denied
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at org.apache.tomcat.util.net.NioEndpoint.initServerSocket(NioEndpoint.java:300)
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:253)
at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1204)
at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1290)
at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:614)
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1071)
... 29 common frames omitted
DockerFile I use to build SCDF Image. I build SCDF jar separately with Oracle driver and just use the below docker file to convert into Dockerimage. This is just to reduce the build time.
DockerFile:
FROM openjdk:8-jre-alpine
WORKDIR /app
COPY src/main/resources/spring-cloud-dataflow-server-2.8.0.jar /app/
ENTRYPOINT ["java", "-jar", "spring-cloud-dataflow-server-2.8.0.jar"]
Thanks.
After a bit of a research, I found the answer for this question. I get the Caused by: java.net.SocketException: Permission denied error. This denotes that the port I'm using which is 80 for SCDF server is not permitted for use in the particular environment. Hence I changed the port to 8081 (Just to have the usual one) and it's started working fine.
This is my first spring-boot application. I ran a sample code and it is getting stuck at "Initialized JPA EntityManagerFactory for persistence unit 'default' ".
Below is the code
package com.fredo.webservices.homefredoServcies;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class HomeFredoServciesApplication {
public static void main(String[] args) {
SpringApplication.run(HomeFredoServciesApplication.class, args);
}
}
below are the logs
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.0.RELEASE)
2020-06-07 20:58:15.807 INFO 1496 --- [ restartedMain] c.f.w.h.HomeFredoServciesApplication : Starting HomeFredoServciesApplication on ANGU with PID 1496 (C:\Users\ASUS\Desktop\java ms\home-fredoServcies\target\classes started by Angu in C:\Users\ASUS\Desktop\java ms\home-fredoServcies)
2020-06-07 20:58:15.811 INFO 1496 --- [ restartedMain] c.f.w.h.HomeFredoServciesApplication : No active profile set, falling back to default profiles: default
2020-06-07 20:58:15.881 INFO 1496 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2020-06-07 20:58:15.882 INFO 1496 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2020-06-07 20:58:16.799 INFO 1496 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
2020-06-07 20:58:16.822 INFO 1496 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 13ms. Found 0 JPA repository interfaces.
2020-06-07 20:58:17.861 INFO 1496 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-06-07 20:58:17.876 INFO 1496 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-06-07 20:58:17.877 INFO 1496 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.35]
2020-06-07 20:58:18.038 INFO 1496 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-06-07 20:58:18.038 INFO 1496 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2156 ms
2020-06-07 20:58:18.100 INFO 1496 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-06-07 20:58:18.335 INFO 1496 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-06-07 20:58:18.342 INFO 1496 --- [ restartedMain] o.s.b.a.h2.H2ConsoleAutoConfiguration : H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:b2c0eff5-9805-4a71-9f66-c6c863d910f5'
2020-06-07 20:58:18.548 INFO 1496 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-06-07 20:58:18.629 INFO 1496 --- [ task-1] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-06-07 20:58:18.674 WARN 1496 --- [ 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-06-07 20:58:18.720 INFO 1496 --- [ task-1] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.15.Final
2020-06-07 20:58:18.966 INFO 1496 --- [ task-1] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-06-07 20:58:19.203 INFO 1496 --- [ task-1] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2020-06-07 20:58:19.210 INFO 1496 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2020-06-07 20:58:19.317 INFO 1496 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2020-06-07 20:58:19.322 INFO 1496 --- [ restartedMain] DeferredRepositoryInitializationListener : Triggering deferred initialization of Spring Data repositories…
2020-06-07 20:58:19.324 INFO 1496 --- [ restartedMain] DeferredRepositoryInitializationListener : Spring Data repositories initialized!
2020-06-07 20:58:19.344 INFO 1496 --- [ restartedMain] c.f.w.h.HomeFredoServciesApplication : Started HomeFredoServciesApplication in 3.985 seconds (JVM running for 4.795)
2020-06-07 20:58:19.554 INFO 1496 --- [ task-1] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-06-07 20:58:19.562 INFO 1496 --- [ task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
I had same problem with application started by Eclipse and Spring Tool Run Configuration in Debug Mode.
A breakpoint was referencing a line on some removed block code, after removing faulty breakpoint, the application start new properly again.
Window-> Show View -> Breakpoints
try to hit http://localhost:8080/h2-console if you get response. your server is up and running. In logs it says H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:b2c0eff5-9805-4a71-9f66-c6c863d910f5'
i am frustrated, Spring boot-hibernate is not a creating a table automatically for simplest program.
#Entity
#Table(name = "Question")
public class Question {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
String id;
String name;
// Default constructor
// Parametrized constrcutor
// Getters-Setters
}
Main file...
#SpringBootApplication
public class DbTestApplication {
public static void main(String[] args) {
SpringApplication.run(DbTestApplication.class, args);
}
}
Application.properties
# Datasource
spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://127.0.0.1:5432/test
spring.datasource.username=scott
spring.datasource.password=tiger
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
Console:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.4.RELEASE)
2017-06-24 23:58:05.497 INFO 4842 --- [ main] org.example.hotel.DbTestApplication : Starting DbTestApplication on PC192-168-2-107 with PID 4842 (/Users/bhalchandra/Documents/workspace-sts-3.8.3.RELEASE/DbTest/target/classes started by bhalchandra in /Users/bhalchandra/Documents/workspace-sts-3.8.3.RELEASE/DbTest)
2017-06-24 23:58:05.504 INFO 4842 --- [ main] org.example.hotel.DbTestApplication : No active profile set, falling back to default profiles: default
2017-06-24 23:58:05.571 INFO 4842 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#2f490758: startup date [Sat Jun 24 23:58:05 CEST 2017]; root of context hierarchy
2017-06-24 23:58:06.755 INFO 4842 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2017-06-24 23:58:06.778 INFO 4842 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2017-06-24 23:58:06.862 INFO 4842 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final}
2017-06-24 23:58:06.864 INFO 4842 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2017-06-24 23:58:06.866 INFO 4842 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2017-06-24 23:58:06.914 INFO 4842 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2017-06-24 23:58:07.071 INFO 4842 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2017-06-24 23:58:07.446 INFO 4842 --- [ main] o.h.e.j.e.i.LobCreatorBuilderImpl : HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
2017-06-24 23:58:07.448 INFO 4842 --- [ main] org.hibernate.type.BasicTypeRegistry : HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType#53b98ff6
2017-06-24 23:58:07.922 INFO 4842 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
2017-06-24 23:58:07.936 INFO 4842 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
2017-06-24 23:58:07.996 INFO 4842 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2017-06-24 23:58:08.364 INFO 4842 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-06-24 23:58:08.380 INFO 4842 --- [ main] org.example.hotel.DbTestApplication : Started DbTestApplication in 3.252 seconds (JVM running for 3.632)
2017-06-24 23:58:08.381 INFO 4842 --- [ Thread-3] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#2f490758: startup date [Sat Jun 24 23:58:05 CEST 2017]; root of context hierarchy
2017-06-24 23:58:08.382 INFO 4842 --- [ Thread-3] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2017-06-24 23:58:08.383 INFO 4842 --- [ Thread-3] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2017-06-24 23:58:08.383 INFO 4842 --- [ Thread-3] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
2017-06-24 23:58:08.386 INFO 4842 --- [ Thread-3] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4-1201-jdbc41</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
This is the simplest program i am trying to create a table using annotation. Finally, no table is created in database. Anybody can help me ?? It seems everything for me.
Seems like you need to enable EntityScan for Spring to find your model classes:
#SpringBootApplication
#EntityScan // <-- find all classes annotated with #Entity
public class DbTestApplication {
public static void main(String[] args) {
SpringApplication.run(DbTestApplication.class, args);
}
}
I found my mistake.
Question Entity is in package org.java.domain
DbTestApplication is in package org.java.dbtest
for spring boot, they must be either in the same package or in sub-package.