Maven项目pom.xml文件plugin插件报红解决方法

 <build>
        <finalName>maven2</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <!-- 设置端口 -->
                    <port>9999</port>
                </configuration>
            </plugin>
        </plugins>
    </build>

以上代码报红,先检查代码是否有问题。
如确定代码没问题可能是你的maven没有设置正确,idea找不到你的setting.xml文件,无法找到依赖文件。

解决方法:
在idea中,选择file -> settings -> Build -> Build Tools -> Maven
在这里找到Maven home path选项,选择你Maven的根目录位置,就可以了。

eclipse同理。

  • 11
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论
根据提供的引用\[1\],当在pom.xml文件中添加以下依赖时,project标签会报错: ```xml <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.8.RELEASE</version> </parent> ``` 为了解决这个问题,可以在parent标签中添加`<relativePath>`标签,如下所示: ```xml <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.8.RELEASE</version> <relativePath></relativePath> </parent> ``` `<relativePath>`标签的作用是指定查找路径。在Maven中,查找依赖的顺序是先查找上级目录的pom.xml文件,然后是本地仓库,最后是远程仓库。如果不指定`<relativePath>`,默认会去上级目录的pom.xml文件中查找。而如果直接加上`<relativePath>`标签并留空,意味着直接去本地仓库查找,然后再去远程仓库查找。 所以,通过添加`<relativePath>`标签并留空,可以解决pom.xml文件中project标签报错的问题。 #### 引用[.reference_title] - *1* [一. 常见bug——pom文件的project标签爆红](https://blog.csdn.net/HSH541/article/details/125897630)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

二饭

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值