将 .jar 许可证文件添加到 Docker 映像的类路径?

我有一个 springboot 应用程序,它连接到 DB2 数据库,然后检索一些数据并为其提供 REST 端点。为了促进这一点,许可证被添加到应用程序的类路径中,以允许它与 DB2 数据库进行通信。这有效。但是,当我在本地构建和镜像并运行该镜像时,我收到一条错误,指出许可证不存在。


{

    "timestamp": 1569854043909,

    "status": 500,

    "error": "Internal Server Error",

    "exception": "org.springframework.jdbc.CannotGetJdbcConnectionException",

    "message": "Could not get JDBC Connection; nested exception is com.ibm.db2.jcc.am.SqlSyntaxErrorException: [jcc][t4][10509][13454][4.26.14] Connection to the data server failed. The IBM Data Server for JDBC and SQLJ license was invalid \nor was not activated for the DB2 for z/OS subsystem. If you are connecting directly to \nthe data server and using DB2 Connect Unlimited Edition for System z, perform the \nactivation step by running the activation program in the license activation kit.  \nIf you are using any other edition of DB2 Connect, obtain the license file, \ndb2jcc_license_cisuz.jar, from the license activation kit, and follow the installation \ndirections to include the license file in the class path. ERRORCODE=-4230, SQLSTATE=42968",

    "path": "/test"

}

我假设这是因为许可证现在不包含在 Docker 容器类路径中。我对此进行了相当多的研究,但看不到任何关于我将如何做到这一点的指示。因此,任何帮助将不胜感激。


我的许可证保存在项目根目录的 lib 文件夹中,是一个 jar 文件。


我的泊坞窗文件:


FROM openjdk:8-jdk-alpine

VOLUME /tmp

ARG JAR_FILE

COPY target/mydb2jdbcproject-1.jar mydb2jdbcproject-1.jar

COPY lib/db2jcc_license_cisuz.jar db2jcc_license_cisuz.jar

#CLASSPATH: lib/db2jcc_license_cisuz.jar/

EXPOSE 8080

ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","mydb2jdbcproject-1.jar"]


慕码人2483693
浏览 74回答 1
1回答

守候你守候我

我最终不得不在运行之前更改用于手动设置多个类路径的 CMD,并且由于某种原因它无法与 -jar 一起使用,因此我必须通过启动器类运行。生成的 dockerfile 如下所示:FROM openjdk:8-jdk-alpineRUN mkdir -p /opt/mvp2/db2jdbc /opt/mvp2/appCOPY target/db2new-0.1.jar /opt/mvp2/app/COPY jdbc/db2jcc4.jar  /opt/mvp2/db2jdbc/COPY jdbc/db2jcc_license_cisuz.jar  /opt/mvp2/db2jdbc/CMD ["java","-classpath","/opt/mvp2/db2jdbc/db2jcc4.jar:/opt/mvp2/db2jdbc/db2jcc_license_cisuz.jar:/opt/mvp2/app/db2new-0.1.jar:.","org.springframework.boot.loader.JarLauncher"]
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java