idea构建Maven项目,出现问题,pom文件灰色带有横线,main方法无法运行,解决办法

这篇具有很好参考价值的文章主要介绍了idea构建Maven项目,出现问题,pom文件灰色带有横线,main方法无法运行,解决办法。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

1.pom文件出现灰色,并且带有横线,可能是因为你频繁删除这个项目,又创建造成的,

        解决办法:找到idea pom.xml灰色横线,intellij-idea,maven,java找到这个页面,把对钩点掉。确定,重启一下idea就OK了。

2.创建的maven项目,无法运行

        八成就是你的maven配置有问题

        我在这假定你已经成功安装了maven,在idea中也成功的导入了。

        如果出现问题,那就是maven的settings.xml文件出现了问题

        我在这给一份我自己配置好的,记得把本地仓库的地址改了。文章来源地址https://www.toymoban.com/news/detail-767791.html

<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<!--
 | This is the configuration file for Maven. It can be specified at two levels:
 |
 |  1. User Level. This settings.xml file provides configuration for a single user,
 |                 and is normally provided in ${user.home}/.m2/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -s /path/to/user/settings.xml
 |
 |  2. Global Level. This settings.xml file provides configuration for all Maven
 |                 users on a machine (assuming they're all using the same Maven
 |                 installation). It's normally provided in
 |                 ${maven.conf}/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -gs /path/to/global/settings.xml
 |
 | The sections in this sample file are intended to give you a running start at
 | getting the most out of your Maven installation. Where appropriate, the default
 | values (values used when the setting is not specified) are provided.
 |
 |-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
	<localRepository>D:\Maven\apache-maven-3.9.1\repository</localRepository>
  <!-- interactiveMode
   | This will determine whether maven prompts you when it needs input. If set to false,
   | maven will use a sensible default value, perhaps based on some other setting, for
   | the parameter in question.
   |
   | Default: true
  <interactiveMode>true</interactiveMode>
  -->

  <!-- offline
   | Determines whether maven should attempt to connect to the network when executing a build.
   | This will have an effect on artifact downloads, artifact deployment, and others.
   |
   | Default: false
  <offline>false</offline>
  -->

  <!-- pluginGroups
   | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
   | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
   | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
   |-->
  <pluginGroups>
    <!-- pluginGroup
     | Specifies a further group identifier to use for plugin lookup.
    <pluginGroup>com.your.plugins</pluginGroup>
    -->
  </pluginGroups>

  <!-- TODO Since when can proxies be selected as depicted? -->
  <!-- proxies
   | This is a list of proxies which can be used on this machine to connect to the network.
   | Unless otherwise specified (by system property or command-line switch), the first proxy
   | specification in this list marked as active will be used.
   |-->
  <proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     |
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
    -->
  </proxies>

  <!-- servers
   | This is a list of authentication profiles, keyed by the server-id used within the system.
   | Authentication profiles can be used whenever maven must make a connection to a remote server.
   |-->
  <servers>
    <!-- server
     | Specifies the authentication information to use when connecting to a particular server, identified by
     | a unique name within the system (referred to by the 'id' attribute below).
     |
     | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
     |       used together.
     |
    <server>
      <id>deploymentRepo</id>
      <username>repouser</username>
      <password>repopwd</password>
    </server>
    -->

    <!-- Another sample, using keys to authenticate.
    <server>
      <id>siteServer</id>
      <privateKey>/path/to/private/key</privateKey>
      <passphrase>optional; leave empty if not used.</passphrase>
    </server>
    -->
  </servers>

  <!-- mirrors
   | This is a list of mirrors to be used in downloading artifacts from remote repositories.
   |
   | It works like this: a POM may declare a repository to use in resolving certain artifacts.
   | However, this repository may have problems with heavy traffic at times, so people have mirrored
   | it to several places.
   |
   | That repository definition will have a unique id, so we can create a mirror reference for that
   | repository, to be used as an alternate download site. The mirror site will be the preferred
   | server for that repository.
   |-->
  <mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
    <mirror>
      <id>maven-default-http-blocker</id>
      <mirrorOf>external:http:*</mirrorOf>
      <name>Pseudo repository to mirror external repositories initially using HTTP.</name>
      <url>http://0.0.0.0/</url>
      <blocked>true</blocked>
    </mirror>


    <mirror>
      <id>nexus-aliyun</id>
      <name>Nexus aliyun</name>
      <url>https://maven.aliyun.com/nexus/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>
    </mirror>


  </mirrors>

  <!-- profiles
   | This is a list of profiles which can be activated in a variety of ways, and which can modify
   | the build process. Profiles provided in the settings.xml are intended to provide local machine-
   | specific paths and repository locations which allow the build to work in the local environment.
   |
   | For example, if you have an integration testing plugin - like cactus - that needs to know where
   | your Tomcat instance is installed, you can provide a variable here such that the variable is
   | dereferenced during the build process to configure the cactus plugin.
   |
   | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
   | section of this document (settings.xml) - will be discussed later. Another way essentially
   | relies on the detection of a property, either matching a particular value for the property,
   | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
   | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
   | Finally, the list of active profiles can be specified directly from the command line.
   |
   | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
   |       repositories, plugin repositories, and free-form properties to be used as configuration
   |       variables for plugins in the POM.
   |
   |-->
  <profiles>
    <!-- profile
     | Specifies a set of introductions to the build process, to be activated using one or more of the
     | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
     | or the command line, profiles have to have an ID that is unique.
     |
     | An encouraged best practice for profile identification is to use a consistent naming convention
     | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
     | This will make it more intuitive to understand what the set of introduced profiles is attempting
     | to accomplish, particularly when you only have a list of profile id's for debug.
     |
     | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
    <profile>
      <id>jdk-1.4</id>

      <activation>
        <jdk>1.4</jdk>
      </activation>

      <repositories>
        <repository>
          <id>jdk14</id>
          <name>Repository for JDK 1.4 builds</name>
          <url>http://www.myhost.com/maven/jdk14</url>
          <layout>default</layout>
          <snapshotPolicy>always</snapshotPolicy>
        </repository>
      </repositories>
    </profile>
    -->

    <!--
     | Here is another profile, activated by the property 'target-env' with a value of 'dev', which
     | provides a specific path to the Tomcat instance. To use this, your plugin configuration might
     | hypothetically look like:
     |
     | ...
     | <plugin>
     |   <groupId>org.myco.myplugins</groupId>
     |   <artifactId>myplugin</artifactId>
     |
     |   <configuration>
     |     <tomcatLocation>${tomcatPath}</tomcatLocation>
     |   </configuration>
     | </plugin>
     | ...
     |
     | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
     |       anything, you could just leave off the <value/> inside the activation-property.
     |
    <profile>
      <id>env-dev</id>

      <activation>
        <property>
          <name>target-env</name>
          <value>dev</value>
        </property>
      </activation>

      <properties>
        <tomcatPath>/path/to/tomcat/instance</tomcatPath>
      </properties>
    </profile>
    -->
  </profiles>

  <!-- activeProfiles
   | List of profiles that are active for all builds.
   |
  <activeProfiles>
    <activeProfile>alwaysActiveProfile</activeProfile>
    <activeProfile>anotherAlwaysActiveProfile</activeProfile>
  </activeProfiles>
  -->
</settings>

到了这里,关于idea构建Maven项目,出现问题,pom文件灰色带有横线,main方法无法运行,解决办法的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • IDEA中maven项目工程中的pom.xml文件变灰且中间有一条横线的处理方法

    错误描述: 不知道是什么原因, pom.xml文件被忽略了,但是之前我也没有过什么误操作。。。  解决方法: 1. File--Settings  2. 搜索 maven,找到 maven 下面的 Ignored Files,将清单中对应项目的pom.xml文件 取消选中 即可; 如果取消选中之后,在 idea 的工作区还是显示 pom.xml 文件中

    2024年02月09日
    浏览(51)
  • idea中maven项目模块变成灰色原因及解决方案

    1、idea中maven项目模块变成灰色 2、原因 可能是忽略了maven模块,可以尝试如下解决方法:在idea中设置setting-》搜索maven-》点击ignored files,看右边的面板中变灰的maven模块是否被勾选pom.xml 3、解决方案 去掉勾选的选项

    2024年02月16日
    浏览(60)
  • 在idea中查找maven包所在的pom文件

    1、点击按ctrl+shift+alt+U打开依赖图界面 2、在依赖图界面中按ctrl+f打开搜索框 3、直接输入想要搜索的依赖包 4、点击依赖名称会跳转到对应的包位置,如果没变化可以尝试点击加号放大 5、双击依赖名称会自动跳转到想要的依赖所在的pom文件中

    2024年02月08日
    浏览(40)
  • 解决IDEA创建Maven项目后报错不出现src文件夹的情况

    在新建Maven项目的时候发现创建以后出现报错,并且没有出现src文件夹,情况如下: 请朋友们思考一下你的maven是否符合以下几种情况: 1. 使用的非IDEA自带的Maven,而是独立在某个盘里的Maven。 2. 你的maven是独立的,并且你的Maven中的repos文件夹(本地仓库)里面的插件使用的

    2024年02月05日
    浏览(55)
  • 【IDEA】pom.xml灰色/pom.xml有删除线

    异常表显情况:pom有删除线、变灰色,检查父工程的pom确认该模块已被引用,但是IDEA标记被删除。 处理方案:依次打开File | Settings | Build, Execution, Deployment | Build Tools | Maven | Ignored Files  保存后记得刷新maven  恢复正常:    分析原因和出现的流程:创建子模块的时候因为名称

    2024年02月09日
    浏览(44)
  • IntelliJ IDEA maven配置,设置pom.xml的配置文件

    IntelliJ IDEA项目,选择  文件  设置,弹窗 构建、执行、部署 构建工具 Maven就可以 maven配置好以后,在pom.xml的配置文件中就可以设置对应的jar包了,这样构建的时候自动需要的jar,在项目中导入即 settings.xml文件apache-maven-3.9.0.rar下载,下载之后解压 到 E:Softapache-maven-3.9.0

    2024年02月11日
    浏览(70)
  • 关于引入maven项目后出现‘parent.relativePath’ of POM错误时的解决方法

    Springboot项目出现的依赖错误。 在Springboot项目启动时,项目报错‘parent.relativePath’ of POM问题,项目无法正常启动。    发生该问题的根本原因是因为在项目文件夹的外层包含着另一个项目,此时项目文件无法确定该文件的pom依赖是引用哪一个parent依赖导致的。推荐使用方法二

    2024年02月13日
    浏览(46)
  • Maven项目提示Ignored pom.xml问题

    1 环境 (1)IDEA开发工具:2022.2.1 (2)JDK:Java17(Spring6要求JDK最低版本是Java17) (3)Spring:6.1.2 (4)Maven 3.8.8 2 问题描述 新创建一个Maven模块,和之前删除的创建失败的模块同名,此时创建好的模块的pom.xml文件有删除线,提示Ignored pom.xml,pom文件显示 pom.xml 。 3 原因分析

    2024年02月04日
    浏览(46)
  • IDEA创建spring boot项目无法加载出maven里的pom.xml,而是settings.gradle

    在创建的maven项目里找不到pom.xml文件而是settings.gradle,如下图所示: 原因和解决方法: 是因为在创建Springboot项目的时候type里选的是Gradle,gradle和maven又不一样,换成maven就行了,具体操作如下图所示: 在用idea创建maven项目时,在Project Metadata界面Type选项下唯有Maven和Maven PO

    2024年02月09日
    浏览(58)
  • idea显示pom.xml文件漂黄警告 Dependency maven:xxx:xxx is vulnerable

    场景: idea警告某些maven依赖包有漏洞或者依赖传递有易受攻击包,如下: 解决: 1、打开idea设置,找到 File | Settings | Editor | Inspections 2、取消上述两项勾选即可  

    2024年02月05日
    浏览(47)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包