我请求帮助构建一个带有Maven项目结构的Spring。我已将项目的文件夹层次结构放入:
C:\ Documents and Settings ... \ Documents \ workspace-sts-3.6.2.RELEASE \ BuildWithMaven \ src \ main \ java \ newProject
在该目录中,我有一个包含以下内容的pom.xml:
http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 org.springframework GS-行家 罐 0.1.0
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>newProject.HelloWorld</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
和两个简单的类Greeter.java(实现)和HelloWorld.java(主类)。
我将MANIFEST.MF与指示的主类放在哪里?
我已经运行了mvn compile,mvn package,mvn install命令,并且“没有要编译的类”消息。我明白我需要一个清单,但是我在哪里放置它以及在那里指示什么?
提前感谢您的帮助。
答案 0 :(得分:0)
感谢您试图帮助我!我已经解决了这个问题。问题是:1。artifactId是应用程序名称。 2.MANIFEST.MF必须至少有一行:Main-Class:src.main.java.hellolanet.HelloPlanet 3. Maven不会创建(至少在此时)一个MANIFEST。程序员(惊喜!)需要在资源文件夹中创建它(与java文件夹处于同一级别。之后,发出java -jar HelloPlanet-0.1.0.jar命令运行jars&#39;内容。那&# 39; s all。这是输出:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building HelloPlanet 0.1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ HelloPlanet ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ HelloPlanet ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ HelloPlanet ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Documents and Settings\...\Documents\workspace-sts-3.6.2.RELEASE\BuildWithMaven\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ HelloPlanet ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ HelloPlanet ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ HelloPlanet ---
[INFO]
[INFO] --- maven-shade-plugin:2.1:shade (default) @ HelloPlanet ---
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing C:\Documents and Settings\...\Documents\workspace-sts-3.6.2.RELEASE \BuildWithMaven\target\HelloPlanet-0.1.0.jar with C:\Documents and Settings\...\Documents\workspace-sts-3.6.2.RELEASE\BuildWithMaven\target\HelloPlanet-0.1.0-shaded.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.141 s
[INFO] Finished at: 2014-12-30T11:00:58-05:00
[INFO] Final Memory: 7M/19M
[INFO] ------------------------------------------------------------------------
C:\Documents and Settings\...\Documents\workspace-sts-3.6.2.RELEASE\Buil
dWithMaven>mvn package > mvn-package.txt
C:\Documents and Settings\...\Documents\workspace-sts-3.6.2.RELEASE\Buil
dWithMaven>cd target
C:\Documents and Settings\...\Documents\workspace-sts-3.6.2.RELEASE\Buil
dWithMaven\target>java -jar HelloPlanet-0.1.0.jar > mvn-jar.txt
C:\Documents and Settings\...\Documents\workspace-sts-3.6.2.RELEASE\Buil
dWithMaven\target>
C:\Documents and Settings\...\Documents\workspace-sts-3.6.2.RELEASE\Buil
dWithMaven>mvn package > mvn-package.txt
C:\Documents and Settings\...\Documents\workspace-sts-3.6.2.RELEASE\Buil
dWithMaven>cd target
C:\Documents and Settings\...\Documents\workspace-sts-3.6.2.RELEASE\Buil
dWithMaven\target>java -jar HelloPlanet-0.1.0.jar > mvn-jar.txt
C:\Documents and Settings\...\Documents\workspace-sts-3.6.2.RELEASE\Buil
dWithMaven\target>
Maven与Ant有点不同。此外,没有Internet连接,不会创建阴影jar(惊喜!)。现在的问题是配置本地存储库。