![](/img/trans.png)
[英]Set up maven plugin connectors in eclipse for “maven-scala-plugin”
[英]Building jar with maven-scala-plugin
我創建了scala應用程序,現在我想構建jar。 我運行mvn package
比嘗試運行jar by命令
java -jar target/burner-1.0-SNAPSHOT.jar
我看到錯誤:
Failed to load Main-Class manifest attribute from
如何定義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中檢查了manifest.mf - 它包含正確的主類但是當我輸入java -jar target/burner-1.0-SNAPSHOT.jar
我仍然看到一個錯誤Failed to load Main-Class manifest attribute from
我的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時覆蓋了它...
在使用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>
對於類test.App ,在使用該命令調用時按需運行
java -jar ./target/mytest-1.0-SNAPSHOT-jar-with-dependencies.jar
運行命令后
mvn package
你可以用這種方式運行jar
scala -cp target / projectname-1.0-SNAPSHOT.jar
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.