推土机与行家 [英] dozer with maven
问题描述
我想从github下载最新版的Dozer映射器,但没有找到任何jar.
I wanted to download the latest release of Dozer mapper from github, but I didn't find any jar.
有pom.xml文件,我尝试使用命令mvn package
进行编译.我还将每个依赖项添加到pom.xml文件中.它创建了dozer-5.5.0-SNAPSHOT.jar
.
There is pom.xml file and I try to compile with command mvn package
. I also added every dependencies to pom.xml file. It created dozer-5.5.0-SNAPSHOT.jar
.
接下来,我将此罐子导入到我的项目中,但是它却抛出了我java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
.
Next I imported this jar to my project, but it throws me java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
.
我还尝试在netbeans中创建POM项目并使用依赖项进行构建.导入我的项目后,它会引发相同的异常.
I also tried to create POM project in the netbeans and build with dependencies. After import to my project, it throws me the same exception.
我对maven没有任何经验.如何获得正确的JAR文件?
I don't have any experiences with maven. How can I get correct JAR file?
推荐答案
猜猜您的dozer-package
对slf4j
有依赖性,对吧?
Guess your dozer-package
has a dependency to slf4j
, right?
然后,您应该检出此Maven-Plugin: Maven-Assembly-Plugin
Then you should checkout this Maven-Plugin: Maven-Assembly-Plugin
这会将所需的依赖项放入jar中.
This will put your required dependencies into the jar.
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
version>2.4</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>your.main.class</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
如果要始终在调用mvn clean package
时执行assemby-plugin
将此添加到您的maven-assembly-plugin:
If you want always execute the assemby-plugin when you invoke mvn clean package
add this to your maven-assembly-plugin:
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
这篇关于推土机与行家的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!