[英]Building jar with maven-scala-plugin
I created scala application and now I want to build jar. 我创建了scala应用程序,现在我想构建jar。 I run mvn package
than I try to run jar by command 我运行mvn package
比尝试运行jar by命令
java -jar target/burner-1.0-SNAPSHOT.jar
and I see error: 我看到错误:
Failed to load Main-Class manifest attribute from
How can I define Main-Class property? 如何定义Main-Class属性? Do I need to create Manifest.mf? 我需要创建Manifest.mf吗? where? 哪里? Or I need to have mainclass property somewhere in pom.xml? 或者我需要在pom.xml中的某个地方使用mainclass属性?
Update: I have created src/main/resources/MANIFEST.MF file with contents 更新:我已经创建了包含内容的src / main / resources / MANIFEST.MF文件
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: itsabear
Main-Class: ru.dmteam.App
Build-Jdk: 1.6.0_20
I did not forget line ending at the end of file. 我没有忘记在文件末尾的行结尾。 after mvn package
I see new jar. 在mvn package
我看到了新罐子。 I checked manifest.mf in this jar - it contains right main-class but when I type java -jar target/burner-1.0-SNAPSHOT.jar
I still see an error Failed to load Main-Class manifest attribute from
我在这个jar中检查了manifest.mf - 它包含正确的主类但是当我输入java -jar target/burner-1.0-SNAPSHOT.jar
我仍然看到一个错误Failed to load Main-Class manifest attribute from
My pom.xml http://pastie.org/1070483 我的pom.xml http://pastie.org/1070483
UPDATE 2 I discovered that now there are two manifest.mf files in the jar. 更新2我发现现在jar中有两个manifest.mf文件。 MANIFEST.MF and META-INF/MANIFEST.MF I moved my custom MANIFEST.MF to just created META-INF folder(in src/main/resources) but now mvn package
overrides it while creating jar... MANIFEST.MF和META-INF / MANIFEST.MF我将我的自定义MANIFEST.MF移动到刚刚创建的META-INF文件夹(在src / main / resources中)但是现在mvn package
在创建jar时覆盖了它...
After creating a new maven project using the scala-archetype-simple archetype (A simple project that prints 'Hello World'), I needed to add the following to my pom.xml 在使用scala-archetype-simple archetype(一个打印'Hello World'的简单项目)创建一个新的maven项目之后,我需要将以下内容添加到我的pom.xml中
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>test.App</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
for the class test.App to run as desired when invoked with the command 对于类test.App ,在使用该命令调用时按需运行
java -jar ./target/mytest-1.0-SNAPSHOT-jar-with-dependencies.jar
After running the command 运行命令后
mvn package
you can run the jar this way 你可以用这种方式运行jar
scala -cp target/projectname-1.0-SNAPSHOT.jar scala -cp target / projectname-1.0-SNAPSHOT.jar
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.