oracle - Spring Boot JNDI 数据源 weblogic 12c
问题描述
我有一个应用程序,当我定义数据源参数时它工作得很好。但是当我尝试放置 jndi 时,它不再起作用了。我的意思是,它不使用 mvn 编译。
如果我在 application.properites 中定义
spring.datasource.url=jdbc:oracle:thin:@dbhost:1521/SERVICE
spring.datasource.username=user
spring.datasource.password=pass
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
我评论上面的行并定义:
spring.datasource.jndi-name=jdbc/Conn
我有这个例外:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/JndiDataSourceAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException: Failed to look up JNDI DataSource with name 'jdbc/Conn'; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
我的 pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.12.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>${ojdbc.version}</version>
</dependency>
解决方案
我知道了。跳过对 maven 命令的测试
推荐阅读
- webpack - 为什么在构建 webpack 时没有替换箭头函数
- c# - C# Automapper:Nullable Boolean 不适用于不同的类成员名称
- javascript - Javascript:如何制作保存文件对话框来保存文件?
- sql-server - 执行进程任务运行成功但未解压缩所需的 .zip 文件-Visual Studio 2019
- php - 如何解决 Laravel 中的 csv 文件读取错误
- python - fbprophet 在 ubuntu 上进行预测时返回内存错误
- python - 有什么方法可以使用python找到word docx文件的结尾
- python - 如何从字符串构造一棵树?
- docker - gerritcodereview/gerrit:XXX 和 gerritcodereview/gerrit:XXX-ubuntuXX 有什么区别?
- python - 截断的 bptt pytorch 实现问题