如何在类路径Spring Boot Jar中添加Ojdbc jar?

时间:2020-04-29 07:51:50

标签: java spring spring-boot

我正在开发Spring Boot应用程序。我使用以下批处理文件运行应用程序:

java -jar -Dspring.config.additional-location=file:/config/ -Dspring.profiles.active=profile myApplication.jar
pause

这很好。但是,我想从我的Pom文件中删除Ojdbc6 jar条目,并通过批处理文件将其定义到我的类路径中,如下所示:

SET CLASSPATH=%CLASSPATH%ojdbc6.jar;
echo %CLASSPATH%
java -jar -Dspring.config.additional-location=file:/config/ -Dspring.profiles.active=profile myApplication.jar --classpath=%CLASSPATH%
pause

这不起作用,并且出现错误:

Unable to create initial connections of pool. 
java.sql.SQLException: Unable to load class: oracle.jdbc.OracleDriver from ClassLoader:org.springframework.boot.loader.LaunchedURLClassLoader@439f5b3d;ClassLoader:TomcatEmbeddedWebappClassLoader

  context: application name

  delegate: true

----------> Parent Classloader:

org.springframework.boot.loader.LaunchedURLClassLoader@439f5b3d

    at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:292)**

1 个答案:

答案 0 :(得分:0)

使用echo '<a id="<id-here>" onclick="generateUrl(this.id)">ABC</a>'; 代替-classpath=%CLASSPATH%

参考链接:https://docs.oracle.com/javase/8/docs/technotes/tools/windows/classpath.html