Встроенный сервер Tomcat не запускается при запуске моего приложения для весенней загрузки. Я только что добавил необходимые зависимости в pom.xml и создал простой Java-класс POJO. Свойства приложения были установлены с необходимыми конфигурациями jdbc, как того требует база данных oracle вместе с информацией о Hibernate Dialect.
Spring boot пытается запустить сервер и немедленно выключает его. В консоли не обнаружено ошибок.
Я уже проверил и подтвердил правильность URL-адреса, имени пользователя и пароля jdbc, так как если я их неверно передал, я заметил другую ошибку.
файл application.properties
#Properties for Oracle connection using Java config
oracle.username=XXXX
oracle.password=XXXX
oracle.url=jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host.oracle.com)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=host.oracle.com)))
spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
spring.jpa.hibernate.ddl-auto=none
pom.xml
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.21.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.app.oracle</groupId>
<artifactId>OMBugDBAnalyzer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>OMBugDBAnalyzer</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.1</version>
</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>
</project>
DBConfig.java
package com.app.oracle.OMBugDBAnalyzer.config;
import oracle.jdbc.pool.OracleDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
import java.sql.SQLException;
@Configuration
@ConfigurationProperties("oracle")
public class DBConfig {
private String username;
private String password;
private String url;
public void setUsername(String username) {
this.username = username;
}
public void setPassword(String password) {
this.password = password;
}
public void setUrl(String url) {
this.url = url;
}
@Bean
DataSource dataSource() throws SQLException {
OracleDataSource dataSource = new OracleDataSource();
dataSource.setUser(username);
dataSource.setPassword(password);
dataSource.setURL(url);
dataSource.setImplicitCachingEnabled(true);
dataSource.setFastConnectionFailoverEnabled(true);
return dataSource;
}
}
Журналы консоли, когда я запускаю mvn spring-boot: run
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.21.RELEASE)
2019-05-24 22:59:17.866 INFO 3704 --- [ main] c.a.o.O.OmBugDbAnalyzerApplication : Starting OmBugDbAnalyzerApplication on vijswami-mac with PID 3704 (/MyExperiments/OMBugDBAnalyzer/target/classes started by vijswami in /MyExperiments/OMBugDBAnalyzer)
2019-05-24 22:59:17.869 INFO 3704 --- [ main] c.a.o.O.OmBugDbAnalyzerApplication : No active profile set, falling back to default profiles: default
2019-05-24 22:59:17.906 INFO 3704 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@7b11b270: startup date [Fri May 24 22:59:17 IST 2019]; root of context hierarchy
2019-05-24 22:59:23.439 INFO 3704 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2019-05-24 22:59:23.455 INFO 3704 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2019-05-24 22:59:23.525 INFO 3704 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final}
2019-05-24 22:59:23.526 INFO 3704 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2019-05-24 22:59:23.528 INFO 3704 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2019-05-24 22:59:23.563 INFO 3704 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2019-05-24 22:59:28.449 INFO 3704 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
2019-05-24 22:59:35.367 INFO 3704 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-05-24 22:59:35.559 INFO 3704 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2019-05-24 22:59:35.568 INFO 3704 --- [ main] c.a.o.O.OmBugDbAnalyzerApplication : Started OmBugDbAnalyzerApplication in 17.906 seconds (JVM running for 20.542)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.608 s
[INFO] Finished at: 2019-05-24T22:59:35+05:30
[INFO] ------------------------------------------------------------------------
2019-05-24 22:59:35.573 INFO 3704 --- [ Thread-4] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@7b11b270: startup date [Fri May 24 22:59:17 IST 2019]; root of context hierarchy
2019-05-24 22:59:35.574 INFO 3704 --- [ Thread-4] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2019-05-24 22:59:35.574 INFO 3704 --- [ Thread-4] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'