需要为不可用的模块配置Maven项目

7

我有一个在Tomcat 8服务器上运行的Java/Maven/JSP项目。项目结构如下:

enter image description here

我有下面提供的这个 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>com.puut.wallet</groupId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <artifactId>WalletApp</artifactId>
    <name>simple-bitcoin-wallet</name>

    <parent>
        <groupId>org.bitcoinj</groupId>
        <artifactId>bitcoinj-parent</artifactId>
        <version>RELEASE</version>
    </parent>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/main/java</directory>
            </resource>
        </resources>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.bitcoinj</groupId>
            <artifactId>bitcoinj-core</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>18.0</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.20</version>
        </dependency>
        <dependency>
            <groupId>net.glxn</groupId>
            <artifactId>qrgen</artifactId>
            <version>1.3</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>

当我运行该项目时,出现以下错误:
Error:Maven Resources Compiler: Maven project configuration required for module 'WalletApp' isn't available. Compilation of Maven projects is supported only if external build is started from an IDE.

我采取了几项措施,


a. in the terminal, run `mvn clean`
b. project -> right click -> `Make Module WalletApp`
c. project -> right click -> `Recompile Module WalletApp`
d. File -> Invalide Caches/Restart .... [This restarts the project]
e. Synchronize 

显然,它们都没有解决问题。顺便说一下,我在项目中使用InteliIJ。我该怎么做来解决这个问题?

尝试这个解决方案 https://dev59.com/u1wY5IYBdhLWcg3w9rwo - Jay Smith
我之前尝试了那个问题的解决方案。它没有起作用,仍然出现相同的错误。 - Arefe
在IDE的右侧,您应该看到一个Maven项目按钮。如果单击,您能在工具窗口中看到您的项目吗?如果没有,请尝试单击小的“刷新”按钮。有任何变化吗?顺便说一句,您的项目结构中缺少target目录,但在将项目导入为maven项目后,它可能会自动创建。此外,您可以在回复某人时使用@user,这样他们就会收到通知 :-) - Morfic
从欢迎界面中删除ipr/iws/iml文件,.idea目录和打开pom.xml以在IntelliJ IDEA中导入Maven项目。 - CrazyCoder
1个回答

10
在“事件日志”中,我有一个选项可以“添加为Maven项目”。我选择了该选项,问题立即得到解决。

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接