微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

springboot 配置数据源

2019独角兽企业重金招聘Python工程师标准>>>

hot3.png

 配置oralce 数据源 :

application.yml

spring:
  datasource:
    driver-class-name:  oracle.jdbc.driver.OracleDriver
    url: jdbc:oracle:thin:@192.168.1.10:1521:ORCL
    username: root
    password: root

pom.xml

 <dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-jpa</artifactId>
		</dependency> 
<-- aliyun仓库的 -->
<groupId>com.hynnet</groupId>
  <artifactId>oracle-driver-ojdbc6</artifactId>
  <version>12.1.0.1</version>
</dependency>

需要注意oracle驱动的版本,版本不对会报错如下

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Bean instantiation via factory method Failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.LocalContainerEntityManagerfactorybean]: Factory method 'entityManagerFactory' threw exception; nested exception is java.lang.AbstractMethodError: oracle.jdbc.driver.T4CConnection.isValid(I)Z

 

转载于:https://my.oschina.net/u/3715963/blog/1833501

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐