【问题标题】:Spring Boot JNDI datasource weblogic 12cSpring Boot JNDI 数据源 weblogic 12c
【发布时间】:2018-05-19 19:57:09
【问题描述】:

我有一个应用程序,当我定义数据源参数时它工作得很好。但是当我尝试放置 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>

【问题讨论】:

    标签: oracle spring-boot weblogic12c spring-jdbc


    【解决方案1】:

    我明白了。跳过对 maven 命令的测试

    【讨论】:

      猜你喜欢
      • 2020-03-06
      • 2015-02-10
      • 1970-01-01
      • 2015-12-11
      • 1970-01-01
      • 2018-10-03
      • 2015-06-11
      • 2016-08-27
      • 2017-02-20
      相关资源
      最近更新 更多