我如何在cmd行中运行Maven项目

kbr*_*bry 5 eclipse cmd jar maven

我编写了maven项目,并在Eclipse中运行了它,但是我想使用命令行来运行maven项目,所以我写了

java -jar -Dapple.awt.UIElement="true" target/myproject-1.0-SNAPSHOT.jar -h
Run Code Online (Sandbox Code Playgroud)

行在cmd中,但出现此错误http://i.stack.imgur.com/c03mN.png

我该如何解决?

小智 20

您可以使用以下命令运行 mavan spring-boot 项目

mvn spring-boot:run


小智 5

  1. cd到命令行中的项目根文件夹。
  2. mvn编译
  3. mvn exec:java -Dexec.mainClass = com.kub.App

请在此处查看更多信息。


que*_*com 2

转到项目:

  1. 打开命令提示符
  2. cd c:/project
  3. mvn clean install
  4. java -jar -Dapple.awt.UIElement="true" target/myproject-1.0-SNAPSHOT.jar -h

在 pom 中添加:

    <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <configuration>
                        <archive>
                            <manifest>
                                <mainClass>com.kub.App</mainClass>
                            </manifest>
                        </archive>
                    </configuration>
                </plugin>
     </plugins>
Run Code Online (Sandbox Code Playgroud)