- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试按照以下结构运行这个 maven
Hello Word:
├── pom.xml
└── src
└── Main.java
使用pom.xml
设置:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>.</groupId>
<artifactId>TestJava</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<!-- https://stackoverflow.com/questions/33124516/can-files-outside-of-the-maven-folder-structure-get-compiled -->
<sourceDirectory>${basedir}/src</sourceDirectory>
<scriptSourceDirectory>${basedir}/src</scriptSourceDirectory>
<testSourceDirectory>${basedir}/src</testSourceDirectory>
<plugins>
<plugin>
<groupId>.</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>Main</mainClass>
<arguments>
<argument>argument1</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</project>
对于文件src/Main.java
:
public class Main {
public static void main(String[] args) {
// Prints "Hello, World" to the terminal window.
System.out.println("Hello, World");
}
}
但是当我使用 mvn exec:java
运行它时出现错误:
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T16:39:06-03:00)
Maven home: D:\User\Documents\apache_marven\maven
Java version: 1.8.0_131, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_65\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "x86", family: "windows"
...
[INFO] Scanning for projects...
[WARNING] The POM for .:exec-maven-plugin:jar:1.2.1 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for .:exec-maven-plugin:1.2.1: Plugin .:exec-maven-plugin:1.2.1 or one of its dependencies could not be resolved: Failure to find .:exec-maven-plugin:jar:1.2.1 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building TestJava 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for .:exec-maven-plugin:jar:1.2.1 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for .:exec-maven-plugin:1.2.1: Plugin .:exec-maven-plugin:1.2.1 or one of its dependencies could not be resolved: Failure to find .:exec-maven-plugin:jar:1.2.1 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
[INFO]
[INFO] --- exec-maven-plugin:1.6.0:java (default-cli) @ TestJava ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.114 s
[INFO] Finished at: 2017-05-13T22:38:28-03:00
[INFO] Final Memory: 7M/18M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project TestJava: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java are missing or invalid -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginParameterException
<小时/>
使用 @Damian Lattenero 答案给我错误:
mvn exec:java
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.mycompany.app:my-app:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 92, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building your proyect name 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.3/maven-dependency-plugin-2.3.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.3/maven-dependency-plugin-2.3.pom (11 kB at 4.8 kB/s)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/21/maven-plugins-21.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/21/maven-plugins-21.pom (12 kB at 33 kB/s)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/20/maven-parent-20.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/20/maven-parent-20.pom (25 kB at 58 kB/s)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.3/maven-dependency-plugin-2.3.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.3/maven-dependency-plugin-2.3.jar (132 kB at 201 kB/s)
[INFO]
[INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) > validate @ my-app >>>
[INFO]
[INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) < validate @ my-app <<<
[INFO]
Downloading: https://repo.maven.apache.org/maven2/org/checkerframework/checker/1.9.4/checker-1.9.4.pom
Downloaded: https://repo.maven.apache.org/maven2/org/checkerframework/checker/1.9.4/checker-1.9.4.pom (4.2 kB at 12 kB/s)
Downloading: https://repo.maven.apache.org/maven2/org/checkerframework/checker-qual/1.9.4/checker-qual-1.9.4.pom
Downloaded: https://repo.maven.apache.org/maven2/org/checkerframework/checker-qual/1.9.4/checker-qual-1.9.4.pom (4.2 kB at 12 kB/s)
Downloading: https://repo.maven.apache.org/maven2/org/checkerframework/jdk8/1.9.4/jdk8-1.9.4.pom
Downloaded: https://repo.maven.apache.org/maven2/org/checkerframework/jdk8/1.9.4/jdk8-1.9.4.pom (4.1 kB at 11 kB/s)
Downloading: https://repo.maven.apache.org/maven2/org/checkerframework/checker/1.9.4/checker-1.9.4.jar
Downloading: https://repo.maven.apache.org/maven2/org/checkerframework/jdk8/1.9.4/jdk8-1.9.4.jar
Downloading: https://repo.maven.apache.org/maven2/org/checkerframework/checker-qual/1.9.4/checker-qual-1.9.4.jar
Downloaded: https://repo.maven.apache.org/maven2/org/checkerframework/jdk8/1.9.4/jdk8-1.9.4.jar (419 kB at 469 kB/s)
Downloaded: https://repo.maven.apache.org/maven2/org/checkerframework/checker-qual/1.9.4/checker-qual-1.9.4.jar (169 kB at 136 kB/s)
Downloaded: https://repo.maven.apache.org/maven2/org/checkerframework/checker/1.9.4/checker-1.9.4.jar (2.3 MB at 667 kB/s)
[INFO]
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) @ my-app ---
[WARNING]
java.lang.ClassNotFoundException: Main
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:285)
at java.lang.Thread.run(Thread.java:748)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.827 s
[INFO] Finished at: 2017-05-13T23:10:39-03:00
[INFO] Final Memory: 7M/19M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project my-app: An exception occured while executing the Java class. your package name -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
<小时/>
并使用 @Steve C 答案,如下:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>.</groupId>
<artifactId>TestJava</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<!-- https://stackoverflow.com/questions/33124516/can-files-outside-of-the-maven-folder-structure-get-compiled -->
<sourceDirectory>${basedir}/src</sourceDirectory>
<scriptSourceDirectory>${basedir}/src</scriptSourceDirectory>
<testSourceDirectory>${basedir}/src</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>Main</mainClass>
<arguments>
<argument>argument1</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</project>
给我错误:
mvn exec:java
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building TestJava 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) > validate @ TestJava >>>
[INFO]
[INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) < validate @ TestJava <<<
[INFO]
[INFO]
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) @ TestJava ---
[WARNING]
java.lang.ClassNotFoundException: Main
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:285)
at java.lang.Thread.run(Thread.java:748)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.271 s
[INFO] Finished at: 2017-05-13T23:14:27-03:00
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project TestJava: An exception occured while executing the Java class. Main -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
最佳答案
您的插件配置不正确:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>Main</mainClass>
<arguments>
<argument>argument1</argument>
</arguments>
</configuration>
</plugin>
我不知道您从哪里得到在任何地方使用 .
作为 groupId 的想法,但我怀疑这不是一个好主意。
接下来,仅执行 mvn exec:java
不会编译您的项目 - 它只是尝试执行它。
尝试:
mvn package exec:java
它将构建一个包含您的类的 jar 文件,然后尝试运行它。
您可能会遇到进一步的问题,因为您的类(class)尚未放置在package structure中.
关于java - 如何在我的文件夹结构中的 Maven 中运行一个简单的 hello 词?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43959623/
我的 CS2 讲师给出了一个 java 正则表达式,用于检查单词是否重复: \\b(\\w+)\\s+\\1\\b 如何修改它来检查某个单词是否重复两次,如“hello hello hello”或“h
关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。 这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topi
这个问题已经有答案了: printf anomaly after "fork()" (3 个回答) 已关闭 3 年前。 #include #include Void main() { Printf
我一直在分配以下作业来解释 3 个语句中发生的事情,但我无法弄清楚。 cout << ("hello" + 1); // ello cout << (*"hello") + 1; // 10
如何确定用户是否使用 hello.js 登录? 使用 Google Sign-In SDK,我可以使用 gapi.auth2.init() 注册回调,当设置 SDK 并准备好回答诸如“你是登录了吗?”
执行String S1 = "hello";后,JVM将在SCP中创建一个String对象,该对象将在value字段中保存一个字符数组,如 s1.value = {'h', 'e', 'l', 'l'
我正在 build gomobile Hello示例应用程序,但遇到以下问题:在 Xcode (7.1) 中打开应用程序后尝试构建并运行该应用程序时,出现错误“找不到 hello/Hello.h”文件
#coding=utf-8 '''Tkinter module''' from Tkinter import * import time root=Tk() t=Text(root,fg='red')
在C/C++中,下面两行代码有什么区别: char *str1="hello"; char *str2={"hello"}; 最佳答案 根据 2011 C 标准,条款 6.7.9 初始化,第 11
我对在 android studio 中导入 import.hello.Hello 时出错有疑问,如下图所示。请给我解决方案如何解决这个错误 最佳答案 请参阅此处 @Arpit Patel answe
hello/ 忽略文件夹结构中任何位置名为“hello”的所有文件夹 hello/* 仅忽略顶级文件夹“hello”。 这是为什么?请指出http://git-scm.com/docs/gitigno
请解释以下程序中发生了什么。 我在程序的开头和结尾检查了 strerror(errno) 返回的地址,并确认它每次都返回相同的地址。然后一旦确定这一点,在第一种情况下我继续将相同的地址分配给 ptr,
在整个互联网上你都会看到这个命令 alias hello='echo Hello' 是的,我知道以上是一个蹩脚的例子,但它不是重点。如果我执行它,它就会起作用。但是当我重新启动计算机时,它丢失了。为什
我正在学习 C++ 指针,而 -> 运算符对我来说似乎很奇怪。代替ptr->hello(); 可以写成 (*ptr).hello(); 因为它似乎也可以工作,所以我认为前者只是更方便方式。 是这样还是
这个问题在这里已经有了答案: About the changing id of an immutable string (5 个回答) 关闭4年前。 为什么 "hello"is "hello" 在 P
我需要Prolog的源代码,它用于与Weka连接,并且能够在Windows环境下使用Weka算法进行预测。我尝试通过 Java 连接,但无法使用 Java 和 Prolog 进行连接和预测。 最佳答案
这个问题已经有答案了: 已关闭11 年前。 Possible Duplicate: Capitalize First Char of Each Word in a String Java 编写进行以下
当我在 ruby 控制台中运行以下示例时,我感到很惊讶。它们都产生相同的输出。 "hello".length 和 "hello" .length ruby
我创建了一个Hello World应用,系统生成了下面大部分的Android语言。在没有 System.out 语句的情况下运行应用程序时,模拟器中不会显示“Hello”。然后,使用 Eclipse
是的,所以我正在制作一个沼泽标准 Hello world 以确保 android 正常工作。这是我第一次使用 android,所以我正在设置环境。我按照以下程序制作了程序:http://develop
我是一名优秀的程序员,十分优秀!