-1
스프링 부트를 처음 사용하고 학습 목적으로 Oracle DB와 함께 스프링 부트 예제를 구현하려고합니다. 저를 안내해줍니다. 내가 뭘 놓치고 있는지 모르겠다. 아래는 오류이며 해결할 수 없습니다.스프링 부트 + 오라클 데이터베이스 관련 문제
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration required a bean of type 'javax.sql.DataSource' that could not be found.
- Bean method 'dataSource' not loaded because @ConditionalOnProperty (spring.datasource.jndi-name) did not find property 'jndi-name'
- Bean method 'dataSource' not loaded because @ConditionalOnBean (types: org.springframework.boot.jta.XADataSourceWrapper; SearchStrategy: all) did not find any beans
Action:
Consider revisiting the conditions above or defining a bean of type 'javax.sql.DataSource' in your configuration.
내가 의 pom.xml에 아래의 종속성을 추가 한 다음
<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-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</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-web-services</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.4.0</version>
</dependency>
</dependencies>
이 내 SpringBootLearningApplication.java
인 application.properties#Tomcat Server Properties
server.port = 8099
#Oracle Database Properties
oracle.username=xxxxx
oracle.password=xxxxx
oracle.url=jdbc:oracle:thin:@localhost:1521:XE
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
#Hibernate Properties
spring.jpa.database-platform=org.hibernate.dialect.OracleDialect
입니다
package com.learning.springboot.main;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan(basePackages = "com.learning.springboot")
@EnableAutoConfiguration(exclude=DataSourceAutoConfiguration.class)
public class SpringBootLearningApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootLearningApplication.class, args);
}
}
UserRepository.java
package com.learning.springboot.dao;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import com.learning.springboot.entity.User;
@Repository
public interface UserRepository extends CrudRepository<User, String> {
}
그리고 내 컨트롤러 클래스 TestController.java
package com.learning.springboot.controller;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import com.learning.springboot.dao.UserRepository;
import com.learning.springboot.entity.User;
@RestController
public class TestController {
@Autowired
UserRepository userRepository;
@GetMapping("/welcome")
public List<User> displayWelcomeMessage() {
List<User> list = new ArrayList<>();
userRepository.findAll().forEach(list::add);
return list;
}
}
는 제가 일부 구성을 놓치고 생각합니다. 친절하게 안내합니다.
https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-connect-to-production-database과 같이해야한다 –