编辑:
我基本上遇到了以下documented issue 。我正在使用 Maven 程序集插件生成一个包含我的依赖项的 jar 文件,以便我的项目可以从单个文件运行。然而,jar 文件似乎没有正确构建。以下是尝试解决该问题的尝试。有人遇到过这个吗?
因此,我尝试构建一个 jar 文件,其中包含所有已打包的依赖项以及已解压的项目工件 jar。
我尝试做一些事情
<assembly>
<id>jar-with-dependencies-packed</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<unpack>true</unpack>
<unpackOptions>
<includes>
<include>artifactname</include>
</includes>
</unpackOptions>
<scope>runtime</scope>
<outputDirectory>lib</outputDirectory>
</dependencySet>
</dependencySets>
</assembly>
但是,生成的 jar 文件仅包含 META-INF 目录...当我说解压,但仅解压我的包含内容时,这是否意味着原始 jar 文件不包含在内?
当我运行 jar 时,我收到以下内容
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace http://www.springframework.org/schema/util
Offending resource: class path resource [applicationContext.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
at org.springframework.beans.fac
tory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:281)
最佳答案
你看一下onejar-maven-plugin吗? 。它以简单的方式完成您想要的事情。
关于java - Maven 依赖项 jar 不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1059193/