maven-docker整合时候,使用mvn docker:build发生javax.activation.DataSource没找到的异常

问题基本分析

初步看错误,是因为没有找到javax.activation.DataSource类的原因导致的错误。

Caused by: java.lang.ClassNotFoundException: javax.activation.DataSource
	at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)

问题分析

印象中javax.activation.DataSource类应该是jdk自带的,不应该找不到才对,后面才发现笔者的jdk环境是jdk13,我们知道javax.activation从jdk11就已经被移除掉了,但是奇怪的是项目在运行的时候没有报错,所以断定是编译的过程依赖到了。所以,解决方案是,给插件添加依赖activation,也就是xml的最后一部分。问题完美解决,解决了的童鞋记得点个赞哦。

解决方案

 <plugin>
  <groupId>com.spotifygroupId>
     <artifactId>docker-maven-pluginartifactId>
     <version>1.0.0version>
     <configuration>
         
         <imageName>192.168.148.132:5000/${project.artifactId}:${project.version} imageName>
         <baseImage>jdk13baseImage>
         <entryPoint>["java", "‐jar", "/${project.build.finalName}.jar"]entryPoint>
         <resources>
             <resource>
                 <targetPath>/targetPath>
                 <directory>${project.build.directory}directory>
                 <include>${project.build.finalName}.jarinclude>
             resource>
         resources>
         
         <dockerHost>http://192.168.148.132:2375dockerHost>
     configuration>
     <dependencies>
         <dependency>
             <groupId>javax.activationgroupId>
             <artifactId>activationartifactId>
             <version>1.1.1version>
         dependency>
     dependencies>
 plugin>

你可能感兴趣的:(JVM)