IDEA项目如何导入pom.xml文件

发布时间:2020-11-07 16:41:03 作者:Leah
来源:亿速云 阅读:2676

这期内容当中小编将会给大家带来有关IDEA项目如何导入pom.xml文件,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

前言

IDEA新建项目和pom.xml文件被修改时,右下角都会出现 Maven projects need to be imported(项目需要导入依赖)

IDEA项目如何导入pom.xml文件

如下,点击 Import Changes导入后,有时会一直处于加载中或导入失败

IDEA项目如何导入pom.xml文件

解决方法

第一种方法:

右击pom.xml文件,选择Maven中的Reimport重新导入项目依赖,一般这种方法都解决不了上面的问题,可直接看下面的方法

IDEA项目如何导入pom.xml文件

第二种方法:

点击 File 选择 Settings… 直接搜索 Maven,在搜索结果中 Maven home directory:默认为Bundled(Maven 3),点击选择IDEA自带的Maven,再点击应用–>OK,重新导入(第一种方法)即可

IDEA项目如何导入pom.xml文件

IDEA项目如何导入pom.xml文件

第三种方法:

若第二种方法还不能解决项目的依赖导入问题,则需要使用国内的Maven类库,IDEA的Maven类库默认都是使用国外的,一些地区由于墙的原因加载会很慢或者加载不了,此时可以导入阿里云的 Maven 类库(一个settings_aliyun.xml文件)来使用,我就是用这个方法才解决的😂😂

pom.xml文件内容

<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/maven-v4_0_0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>com.tcl.kuyu.salesreport</groupId>
 <artifactId>salesreport-server</artifactId>
 <packaging>war</packaging>
 <version>1.0-SNAPSHOT</version>
 <name>salesreport-server</name>
 <url>http://maven.apache.org</url>

<!-- 刚开始的时候,我很不习惯,也不太理解为什么要用下面的标签,后来才觉得,代码就该这样。。。修改的时候也会特别的方便 -->
 <properties>
  <aspectj.version>1.8.9</aspectj.version>
  <java.version>1.8</java.version>
  <junit.version>4.12</junit.version>
  <logback.version>1.1.7</logback.version>
  <logback-ext-spring.version>0.1.4</logback-ext-spring.version>
  <mysql.driver.version>5.1.38</mysql.driver.version>
  <slf4j.version>1.7.21</slf4j.version>
  <spring.version>4.2.5.RELEASE</spring.version>
  <jackson.version>2.5.2</jackson.version>
  <mybatis.version>3.4.0</mybatis.version>
  <mybatis.spring.version>1.3.0</mybatis.spring.version>
  <mybatis-plus.version>1.2.16</mybatis-plus.version>
  <fastjson.version>1.2.11</fastjson.version>
  <shiro.version>1.2.6</shiro.version>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <jetty.web.xml>${basedir}/jetty-webdefault.xml</jetty.web.xml>
 </properties>


 <dependencies>
  <!-- junit 此处是单元测试的依赖-->
  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>${junit.version}</version>
   <scope>test</scope>
  </dependency>

  <dependency>
   <groupId>junitperf</groupId>
   <artifactId>junitperf</artifactId>
   <version>1.8</version>
   <scope>test</scope>
  </dependency>

  <!-- spring -->
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-aop</artifactId>
   <version>${spring.version}</version>
  </dependency>

  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-aspects</artifactId>
   <version>${spring.version}</version>
  </dependency>

  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-beans</artifactId>
   <version>${spring.version}</version>
  </dependency>

  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-context</artifactId>
   <version>${spring.version}</version>
  </dependency>

  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-context-support</artifactId>
   <version>${spring.version}</version>
  </dependency>

  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-core</artifactId>
   <version>${spring.version}</version>
  </dependency>

  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-expression</artifactId>
   <version>${spring.version}</version>
  </dependency>

  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-jdbc</artifactId>
   <version>${spring.version}</version>
  </dependency>

  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-jms</artifactId>
   <version>${spring.version}</version>
  </dependency>

  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-orm</artifactId>
   <version>${spring.version}</version>
  </dependency>

  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-oxm</artifactId>
   <version>${spring.version}</version>
  </dependency>

  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-test</artifactId>
   <version>${spring.version}</version>
   <scope>test</scope>
  </dependency>

  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-tx</artifactId>
   <version>${spring.version}</version>
  </dependency>

  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-web</artifactId>
   <version>${spring.version}</version>
  </dependency>

  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-webmvc</artifactId>
   <version>${spring.version}</version>
  </dependency>

  <dependency>
   <groupId>commons-dbcp</groupId>
   <artifactId>commons-dbcp</artifactId>
   <version>1.4</version>
  </dependency>


  <!-- freemark  根据项目需要,简单的web项目的话此处是不需要的-->
  <dependency>
   <groupId>org.freemarker</groupId>
   <artifactId>freemarker</artifactId>
   <version>[2.3.19,2.4)</version>
  </dependency>

  <dependency>
   <groupId>commons-httpclient</groupId>
   <artifactId>commons-httpclient</artifactId>
   <version>3.1</version>
  </dependency>

  <dependency>
   <groupId>org.apache.commons</groupId>
   <artifactId>commons-lang3</artifactId>
   <version>3.1</version>
  </dependency>

   <dependency>
    <groupId>commons-collections</groupId>
    <artifactId>commons-collections</artifactId>
    <version>3.2.2</version>
   </dependency>

   <dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>${fastjson.version}</version>
   </dependency>

  <!-- logback begin -->
  <dependency>
   <groupId>org.slf4j</groupId>
   <artifactId>slf4j-api</artifactId>
   <version>${slf4j.version}</version>
  </dependency>

  <dependency>
   <groupId>ch.qos.logback</groupId>
   <artifactId>logback-core</artifactId>
   <version>${logback.version}</version>
  </dependency>

  <dependency>
   <groupId>ch.qos.logback</groupId>
   <artifactId>logback-classic</artifactId>
   <version>${logback.version}</version>
  </dependency>
  <!-- logback end -->

  <dependency>
   <groupId>org.aspectj</groupId>
   <artifactId>aspectjrt</artifactId>
   <version>${aspectj.version}</version>
  </dependency>
  <dependency>
   <groupId>org.aspectj</groupId>
   <artifactId>aspectjweaver</artifactId>
   <version>${aspectj.version}</version>
  </dependency>

  <dependency>
   <groupId>mysql</groupId>
   <artifactId>mysql-connector-java</artifactId>
   <version>${mysql.driver.version}</version>
  </dependency>

  <dependency>
   <groupId>org.mybatis</groupId>
   <artifactId>mybatis</artifactId>
   <version>${mybatis.version}</version>
  </dependency>
  <dependency>
   <groupId>org.mybatis</groupId>
   <artifactId>mybatis-spring</artifactId>
   <version>${mybatis.spring.version}</version>
  </dependency>
   <dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus</artifactId>
    <version>${mybatis-plus.version}</version>
   </dependency>

  <dependency>
   <groupId>com.fasterxml.jackson.core</groupId>
   <artifactId>jackson-databind</artifactId>
   <version>${jackson.version}</version>
  </dependency>

  <dependency>
   <groupId>com.fasterxml.jackson.core</groupId>
   <artifactId>jackson-core</artifactId>
   <version>${jackson.version}</version>
  </dependency>

  <dependency>
   <groupId>commons-fileupload</groupId>
   <artifactId>commons-fileupload</artifactId>
   <version>1.3.1</version>
  </dependency>

  <dependency>
   <groupId>javax.servlet.jsp</groupId>
   <artifactId>jsp-api</artifactId>
   <version>2.2</version>
   <scope>provided</scope>
  </dependency>

  <dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>servlet-api</artifactId>
   <version>2.5</version>
   <scope>provided</scope>
  </dependency>

 <dependency>
  <groupId>com.mangofactory</groupId>
  <artifactId>swagger-springmvc</artifactId>
  <version>1.0.2</version>
 </dependency>

 <dependency>
  <groupId>com.fasterxml.jackson.core</groupId>
  <artifactId>jackson-annotations</artifactId>
  <version>${jackson.version}</version>
 </dependency>

   <dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>druid</artifactId>
    <version>1.0.18</version>
   </dependency>

   <dependency>
    <groupId>javassist</groupId>
    <artifactId>javassist</artifactId>
    <version>3.12.1.GA</version>
   </dependency>

   <!-- shiro权限管理 -->
   <dependency>
     <groupId>org.apache.shiro</groupId>
     <artifactId>shiro-core</artifactId>
     <version>${shiro.version}</version>
   </dependency>
   <dependency>
     <groupId>org.apache.shiro</groupId>
     <artifactId>shiro-web</artifactId>
     <version>${shiro.version}</version>
   </dependency>
   <!-- 如果要与spring集成,需要添加此依赖 -->
   <dependency>
     <groupId>org.apache.shiro</groupId>
     <artifactId>shiro-spring</artifactId>
     <version>${shiro.version}</version>
   </dependency>
   <!-- shiro权限管理 -->

  </dependencies>

 <build>
  <finalName>salesreport</finalName>

<!--下面的resources里面的配置,大家可以根据自身项目需要进行选择和修改-->
  <resources>
   <resource>
    <directory>src/main/resources/commons</directory>
    <filtering>true</filtering>
    <includes>
     <include>**/*.*</include>
    </includes>
   </resource>
   <resource>
    <directory>src/main/resources/${env}</directory>
    <filtering>true</filtering>
    <includes>
     <include>**/*.*</include>
    </includes>
   </resource>
  </resources>

  <plugins>
   
  <!-- 编译插件 -->  
  <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
      <source>1.8</source>
      <target>1.8</target>
      <encoding>UTF-8</encoding>
    </configuration>
  </plugin>
  
  <!-- 单元测试插件 -->
  <plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-surefire-plugin</artifactId>
   <version>2.19</version>
   <configuration>
    <skipTests>true</skipTests>
   </configuration>
  </plugin>

  <!--jetty 插件,mvn jetty:run -->
   <plugin>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>9.3.7.v20160115</version>
    <configuration>
     <webApp>
      <webDefaultXml>${jetty.web.xml}</webDefaultXml>
      <contextPath>/</contextPath>
      <descriptor>${basedir}/src/main/webapp/WEB-INF/web.xml</descriptor>
     </webApp>
     <stopKey>exit</stopKey>
     <stopPort>9091</stopPort>
     <webAppSourceDirectory>${project.basedir}/src/main/webapp</webAppSourceDirectory>
     <scanIntervalSeconds>0</scanIntervalSeconds>
     <httpConnector>
      <port>8080</port>
     </httpConnector>
    </configuration>
   </plugin>
 
  </plugins>


 </build>

 <profiles>
  <profile>
   <id>dev</id>
   <activation>
    <activeByDefault>true</activeByDefault>
   </activation>
   <properties>
    <env>dev</env>
   </properties>
  </profile>
  <profile>
   <id>sit</id>
   <properties>
    <env>sit</env>
   </properties>
  </profile>
  <profile>
   <id>prod</id>
   <properties>
    <env>prod</env>
   </properties>
  </profile>
  <profile>
   <id>uat</id>
   <properties>
    <env>uat</env>
   </properties>
  </profile>
 </profiles>

 
</project>

导入xml文件:进入第二种方法的 Maven 界面勾选右侧第一个Override

IDEA项目如何导入pom.xml文件

按第一种方法重新导入一下即可

IDEA项目如何导入pom.xml文件

上述就是小编为大家分享的IDEA项目如何导入pom.xml文件了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注亿速云行业资讯频道。

推荐阅读:
  1. idea导入多模块项目的步骤
  2. idea与eclipse项目怎么实现相互导入

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

idea pom.xml %d

上一篇:Tomcat项目中出现404如何解决

下一篇:如何卸载重装Tomcat

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》