Jetty 9 与 Oracle 11g 连接问题
Jetty 9 with Oracle 11g connection issue
Jetty 无法连接到 Oracle。
在我的 jetty conf 中我有
<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 clean install jetty:run -Djetty.port=8888
我有错误
java.lang.ClassNotFoundException: oracle.jdbc.pool.OracleConnectionPoolDataSource in file:/C:/workspace/rest-api/src/main/resources/config/jetty9.xml
通过将依赖项添加到 maven jetty 插件解决了问题
<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>
Jetty 无法连接到 Oracle。
在我的 jetty conf 中我有
<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 clean install jetty:run -Djetty.port=8888
我有错误
java.lang.ClassNotFoundException: oracle.jdbc.pool.OracleConnectionPoolDataSource in file:/C:/workspace/rest-api/src/main/resources/config/jetty9.xml
通过将依赖项添加到 maven jetty 插件解决了问题
<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>