使用 maven-scala-plugin 构建 jar
我创建了 scala 应用程序,现在我想构建 jar。 我运行 mvn package
比我尝试通过命令
java -jar target/burner-1.0-SNAPSHOT.jar
运行 jar并看到错误:
无法加载 Main -Class 清单属性来自
如何定义 Main-Class 属性? 我需要创建Manifest.mf吗?在哪里? 或者我需要在 pom.xml 中的某个地方拥有 mainclass 属性?
更新: 我已经创建了 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
我没有忘记文件末尾的行结尾。 在mvn package
之后我看到了新的jar。我检查了这个 jar 中的 manifest.mf - 它包含正确的主类,但是当我输入 java -jar target/burner-1.0-SNAPSHOT.jar
时,我仍然看到错误 Failed to load Main 的类清单属性
- 来自 我的 pom.xml http://pastie.org/1070483
更新2 我发现现在jar中有两个manifest.mf文件。 MANIFEST.MF 和 META-INF/MANIFEST.MF 我将自定义 MANIFEST.MF 移至刚刚创建的 META-INF 文件夹(在 src/main/resources 中),但现在 mvn package
在创建 jar 时覆盖它...
I created scala application and now I want to build jar.
I run mvn package
than I try to run jar by command
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?
Do I need to create Manifest.mf? where?
Or I need to have mainclass property somewhere in pom.xml?
Update:
I have created src/main/resources/MANIFEST.MF file with contents
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. 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
My pom.xml http://pastie.org/1070483
UPDATE 2
I discovered that now there are two manifest.mf files in the jar.
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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 scala-archetype-simple 原型创建新的 Maven 项目(一个打印“Hello World”的简单项目)后,我需要将以下内容添加到
类 test.App 的 pom.xml 中使用命令调用时根据需要运行
运行命令后
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
for the class test.App to run as desired when invoked with the command
After running the command
你可以这样运行jar
scala -cp target/projectname-1.0-SNAPSHOT.jar
you can run the jar this way
scala -cp target/projectname-1.0-SNAPSHOT.jar