简体   繁体   中英

How to configure Oracle to Spring boot application

I want to set up spring boot latest project with the Oracle database. i did fw steps 1. Download ojdbc7 12.1.0.1 jar and keep it in "C:\\Users\\Dasun_09323.m2\\repository\\com\\oracle\\ojdbc7".

2.using maven command i installed that jar. 3.added this gradle dependency, compile group: 'cn.easyproject', name: 'ojdbc7', version: '12.1.0.1'.

Than i open the terminal in intelliJ idea and hit gradle build -x test to build the project but BUILD FAILED ..

Execution failed for task ':compileJava'.

Could not resolve all files for configuration ':compileClasspath'. Could not find cn.easyproject:ojdbc7:12.1.0.1. Required by: project :

How to fix this issue ? this ate my 3 days of working.

Based on the error it looks like you have not added the entry in your .m2 correctly.

Verify that the jar exists in :\\Users\\Dasun_09323.m2\\repository\\cn\\easyproject

If it exists then you can get the entries from pom.xml file in the dependency and make sure it matches what you are using in gradle.

Gradle

dependencies {
    compile("org.springframework.boot:spring-boot-starter-data-jpa")

}

Maven

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <version>1.5.3.RELEASE</version>
        </dependency>

to use CrudRepository more info here https://docs.spring.io/spring-data/data-commons/docs/1.6.1.RELEASE/reference/html/repositories.html

in your application properties

# Oracle settings

spring.datasource.url=jdbc:oracle:thin:@localhost:1522:orcl

spring.datasource.username=HIBERNATE_TEST

spring.datasource.password=HIBERNATE_TEST

spring.datasource.driver.class=oracle.jdbc.driver.OracleDriver

here is a good article on dzone https://dzone.com/articles/spring-boot-jpa-hibernate-oracle

Using the oracle driver is answered in this post How to use Oracle JDBC driver in Gradle project

I just created a directory called Lib and upload oracle driver jar into it. then i removed the dependency for the oracle and i just added. this line in under the dependency corner.

compile fileTree(include: ['*.jar'], dir: 'lib')

Add repository on your project' pom file, in the repositories tag:

  <repository>
        <id>ICM</id>
        <name>ICM project repository</name>
        <url>https://mvnrepository.com/artifact/repo</url>
  </repository>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM