docker添加jar包,如何在Docker中从系统路径添加jar

In my maven pom file I have some dependencies which are our own jar files from other projects which are not in repository.We have used 'system' scoped dependencies like

efaadmin

efaadmin

system

1.0

${basedir}\src\main\webapp\WEB-INF\lib\efaadmin.jar

Now when writing Dockerfile these dependencies have become our stumbling block.

#

# Build stage

#

FROM maven:3.6.1-jdk-8-slim AS BUILD

COPY src /home/app/src

COPY pom.xml /home/app

COPY jars/*.jar /home/app/jars/

RUN mvn -f /home/app/pom.xml

#

# Package stage

#

FROM tomcat:7.0-jdk8-openjdk-slim

ENV CATALINA_HOME /usr/local/tomcat

ENV PATH $CATALINA_HOME/bin:$PATH

COPY --from=build /home/app/target/DrySign.war $CATALINA_HOME/webapps/

COPY --from=build /home/app/target/jars/* $CATALINA_HOME/webapps/xxxxx/WEB-INF/lib/

EXPOSE 8080

CMD ["catalina.sh", "run"]

But docker is complaining:

'dependencies.dependency.systemPath' for efaadmin:efaadmin:jar must specify an absolute path but is ./jars/efaadmin.jar

How to deal with this?

解决方案

This does not look like an issue with Docker, it looks like an issue with Maven. Maven requires an absolute path for system scope dependencies. You can test this is the case by commenting out all the lines of your Dockerfile below

...

RUN mvn -f /home/app/pom.xml

# comment out everything below this, I think you'll still see the failure

By the way, why are you using backslashes not forward slashes for your systemPath? Your Maven system scoped dependencies are being interpreted as relative paths, not absolute paths. When you fix this, your build should work as intended.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值