Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/350.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Maven项目在IntelliJ中构建良好,但不使用Maven命令行_Java_Maven_Intellij Idea - Fatal编程技术网

Java Maven项目在IntelliJ中构建良好,但不使用Maven命令行

Java Maven项目在IntelliJ中构建良好,但不使用Maven命令行,java,maven,intellij-idea,Java,Maven,Intellij Idea,当我跑步时: mvn 我得到以下错误: 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 171, column 21 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-war-plugin is missing. @ line 179, column 21 在构

当我跑步时:

mvn

我得到以下错误:

'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 171, column 21
'build.plugins.plugin.version' for org.apache.maven.plugins:maven-war-plugin is missing. @ line 179, column 21
在构建失败块中,我看到:

No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
我确实是通过以下方式实现的:

org.junit.Assert.assertTrue(a==b)


很奇怪为什么IntelliJ没有告诉我在这里导入什么,我甚至尝试添加都无法让它工作:
import org.junit.Assert

您不需要运行mvn

您需要运行类似于mvn编译或mvn包的程序


此外,您似乎还缺少编译器插件和war插件的版本。您可以发布pom.xml来告诉您在哪里解决这个问题吗?

您不需要运行mvn

您需要运行类似于mvn编译或mvn包的程序


此外,您似乎还缺少编译器插件和war插件的版本。你能发布pom.xml来告诉你在哪里解决这个问题吗?

你必须用一个目标调用maven,例如

mvn clean
mvn package
mvn install
此时可以忽略缺少版本警告。但是,您应该将这些版本添加到pom.xml中

当您使用junit调用Spring中的test时:

mvn test

这也是一个有效的目标。

您必须使用一个目标调用maven,例如

mvn clean
mvn package
mvn install
此时可以忽略缺少版本警告。但是,您应该将这些版本添加到pom.xml中

当您使用junit调用Spring中的test时:

mvn test

这也是一个有效的目标。

要消除恼人的版本警告,请首先添加它们:-

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        ...
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.1.1</version>
        ...
    </plugin>
    ...
</plugins>

org.apache.maven.plugins
. 配置好后,在键入任何assert语句后,它将得到很好的解析。您可以在此处添加其他有用的
import static
,例如,如果您正在使用等

正如其他人提到的,当您通过命令行运行
mvn
命令时,需要在
mvn
之后指定一个目标。如果单击Intellij右侧导航栏上的“Maven项目”,然后展开下拉列表,您将看到通常通过Intellij调用的所有列出的可使用目标(清理、验证、编译、测试等)。这是一个例子


如果我是你,我会直接从Intellij而不是通过命令行运行maven goals,但这确实是一种偏好。。。两种方法都有效

要消除恼人的版本警告,请先添加它们:-

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        ...
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.1.1</version>
        ...
    </plugin>
    ...
</plugins>

org.apache.maven.plugins
. 配置好后,在键入任何assert语句后,它将得到很好的解析。您可以在此处添加其他有用的
import static
,例如,如果您正在使用等

正如其他人提到的,当您通过命令行运行
mvn
命令时,需要在
mvn
之后指定一个目标。如果单击Intellij右侧导航栏上的“Maven项目”,然后展开下拉列表,您将看到通常通过Intellij调用的所有列出的可使用目标(清理、验证、编译、测试等)。这是一个例子


如果我是你,我会直接从Intellij而不是通过命令行运行maven goals,但这确实是一种偏好。。。两种方法都有效

mvn
需要一个目标。您可能想运行
mvn包
缺少的版本只是一个警告。如果未指定版本,则使用可用的最新版本。这可能会在将来导致问题,但可能不需要担心。
mvn
需要一个目标。您可能想运行
mvn包
缺少的版本只是一个警告。如果未指定版本,则使用可用的最新版本。这可能会在将来引起问题,但可能没什么可担心的。嗨,我正在使用Intellij 9。我在对话框中添加了引用,选中了静态复选框,仍然没有做任何事情。那我怎么能手动操作呢?导入org.junit.Assert;根本不管用!好了,现在它可以使用Assert.assertTrue进行导入(手动)。@Blankman,我认为v9也可以正常工作。键入
assertTrue
时,需要在该语句上按ALT+ENTER键。。。您将看到一个弹出窗口“静态导入方法…”。它不会自动为您插入静态导入,这与Eclipse非常不同。我认为您不想执行
Assert.assertTrue(..)
,因为当它工作时,它往往会用这些前缀将您的测试用例弄得乱七八糟。嗨,我使用的是Intellij 9。我在对话框中添加了引用,选中了静态复选框,仍然没有做任何事情。那我怎么能手动操作呢?导入org.junit.Assert;根本不管用!好了,现在它可以使用Assert.assertTrue进行导入(手动)。@Blankman,我认为v9也可以正常工作。键入
assertTrue
时,需要在该语句上按ALT+ENTER键。。。您将看到一个弹出窗口“静态导入方法…”。它不会自动为您插入静态导入,这与Eclipse非常不同。我认为您不想执行
Assert.assertTrue(..)
,因为当它工作时,它往往会用这些前缀将您的测试用例弄得乱七八糟。