Jetty 9与Oracle 11g连接问题

时间:2016-03-21 10:42:35

标签: spring hibernate maven-3 jetty-9

Jetty无法连接到Oracle。

在我的码头中,我有

 <New id="demoRestLegacyDS"  class="org.eclipse.jetty.plus.jndi.Resource">
 <Arg></Arg>
 <Arg>jdbc/demoRestLegacyDB</Arg>
 <Arg>
    <New class="oracle.jdbc.pool.OracleDataSource">
       <Set name="Url">jdbc:oracle:thin:@localhost:1521/MySchema</Set>
       <Set name="User">TEST</Set>
       <Set name="Password">TEST</Set>
    </New>
 </Arg>
</New>   

我在maven依赖项中添加了jar

    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc14</artifactId>
        <version>10.2.0.4.0</version>
        <scope>provided</scope>
    </dependency>

但是,当我使用 mvn清理安装jetty运行时:运行-Djetty.port = 8888

我有错误

java.lang.ClassNotFoundException: oracle.jdbc.pool.OracleConnectionPoolDataSource in file:/C:/workspace/rest-api/src/main/resources/config/jetty9.xml

1 个答案:

答案 0 :(得分:0)

通过将依赖项添加到maven jetty pluggin

解决了该问题
            <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>${jetty.maven.plugin.version}</version>
            <configuration>
                <jettyXml>${project.basedir}/src/main/resources/config/jetty9.xml</jettyXml>
                <!-- ,${project.basedir}/src/main/resources/config/jetty-ssl.xml, ${project.basedir}/src/main/resources/config/jetty-https.xml -->
                <stopKey>STOP</stopKey>
                <stopPort>9999</stopPort>
                <stopWait>5</stopWait>
                <scanIntervalSeconds>5</scanIntervalSeconds>
                <scanTargets>
                    <scanTarget>${project.basedir}/src/main</scanTarget>
                    <scanTarget>${project.basedir}/src/test</scanTarget>
                </scanTargets>
                <contextXml>${project.basedir}/src/test/resources/jetty-context.xml</contextXml>
                <webAppConfig>
                    <contextPath>/${project.artifactId}</contextPath>
                </webAppConfig>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>mysql</groupId>
                    <artifactId>mysql-connector-java</artifactId>
                    <version>5.1.27</version>
                </dependency>
                <dependency>
                    <groupId>com.oracle</groupId>
                    <artifactId>ojdbc14</artifactId>
                    <version>10.2.0.4.0</version>
                </dependency>
            </dependencies>
        </plugin>