简体   繁体   English

使用InteliJ在Maven项目中创建jar

[英]Creating a jar in a maven project using InteliJ

I'm all new to java and need to create an executable jar from InteliJ. 我是java的新手,需要从InteliJ创建一个可执行jar。 It is a maven project and I don't really understand what I'm doing wrong. 这是一个行家项目,我不太了解自己在做什么错。 When creating the jar using right-click on src folder and choosing "Make Module" everything is ok and I can run it on the UNIX machine. 使用右键单击src文件夹并选择“ Make Module”创建jar时,一切正常,我可以在UNIX计算机上运行它。 BUT when I'm using the maven->Lifecycle->install I get an error: 但是当我使用Maven-> Lifecycle-> install时出现错误:

 Exception in thread "main" java.lang.NoClassDefFoundError: taglib/Tagger
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at Launcher.main(Launcher.java:10)

few more things: this project using another jar created with "install", when opening the pom.xml file I get the pom of the other project (stated before). 还有几件事:这个项目使用另一个通过“安装”创建的jar,打开pom.xml文件时,我得到了另一个项目的pom(之前已陈述)。

As I said I'm very new to all of this and especially maven and would like to understand. 正如我说的那样,我对所有这些都非常陌生,尤其是行家,并且想了解。

Regards. 问候。

If its a maven project, you can simply create jar by using command mvn clean install from cmd, provided you have set your PATH variable properly. 如果它是一个maven项目,则只要已正确设置了PATH变量,就可以使用来自cmd的命令mvn clean install创建jar。 It will delete target directory and publish new jar there. 它将删除目标目录并在那里发布新的jar。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM