问答详情
源自:3-5 Hello Spring MVC

用ECLIPSE 导入MAVEN项目后,POM.XML该怎么写

在eclipse里导入一个maven项目后,POM.XML该怎么改写呢,老师在视频教程里好像是从其它地方拷贝来的代码,但是没有细说是从哪来的!我已经提过一个这个问题,有人让我去听maven课程,我去听了,但是课程中讲的重点是maven的原理,没有讲到我想要问的方面的详解,请高手赐教

提问者:水里的石头 2016-06-09 12:22

个回答

  • 小杨小宇
    2016-06-29 10:53:33
    已采纳

    <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.education</groupId>

      <artifactId>educationcrm</artifactId>

      <packaging>war</packaging>

      <version>1.0-SNAPSHOT</version>

      <name>educationcrm Maven Webapp</name>

      <url>http://maven.apache.org</url>


      <properties>

        <!-- spring版本号 -->

        <spring.version>4.0.2.RELEASE</spring.version>

        <!-- mybatis版本号 -->

        <mybatis.version>3.2.6</mybatis.version>

        <!-- log4j日志文件管理包版本 -->

        <slf4j.version>1.7.7</slf4j.version>

        <log4j.version>1.2.17</log4j.version>

      </properties>


      <!-- 指定maven仓库 -->

      <repositories><!-- 发现依赖和扩展的远程资源库 -->

        <repository>

          <id>CN</id>

          <name>OSChina Central</name>

          <layout>default</layout>

          <url>http://maven.oschina.net/content/groups/public/</url>

          <snapshots>

            <enabled>false</enabled>

          </snapshots>

        </repository>

        <!-- maven自己官方仓库 -->

        <repository>

          <id>maven</id>

          <name>Maven Repository Switchboard</name>

          <layout>default</layout>

          <url>http://repo1.maven.org/maven2</url>

          <snapshots>

            <enabled>false</enabled>

          </snapshots>

        </repository>

        <!-- 阿里巴巴发布版本仓库 -->

        <repository>

          <id>alibaba-opensource</id>

          <name>alibaba-opensource</name>

          <url>http://code.alibabatech.com/mvn/releases/</url>

          <layout>default</layout>

        </repository>

        <!-- 阿里巴巴快照版本仓库 -->

        <repository>

          <id>alibaba-opensource-snapshot</id>

          <name>alibaba-opensource-snapshot</name>

          <url>http://code.alibabatech.com/mvn/snapshots/</url>

          <layout>default</layout>

        </repository>

      </repositories>




      <dependencies>


        <dependency>

          <groupId>junit</groupId>

          <artifactId>junit</artifactId>

          <version>4.11</version>

          <!-- 表示开发的时候引入,发布的时候不会加载此包 -->

          <scope>test</scope>

        </dependency>


        <dependency>

          <groupId>org.springframework</groupId>

          <artifactId>spring-core</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-oxm</artifactId>

          <version>${spring.version}</version>

        </dependency>

        <dependency>

          <groupId>org.springframework</groupId>

          <artifactId>spring-tx</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-webmvc</artifactId>

          <version>${spring.version}</version>

        </dependency>

        <dependency>

          <groupId>org.springframework</groupId>

          <artifactId>spring-aop</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-test</artifactId>

          <version>${spring.version}</version>

        </dependency>


        <!-- mybatis核心包 -->

        <dependency>

          <groupId>org.mybatis</groupId>

          <artifactId>mybatis</artifactId>

          <version>${mybatis.version}</version>

        </dependency>

        <!-- mybatis/spring包 -->

        <dependency>

          <groupId>org.mybatis</groupId>

          <artifactId>mybatis-spring</artifactId>

          <version>1.2.2</version>

        </dependency>


        <!-- 导入java ee jar 包 -->

        <dependency>

          <groupId>javax</groupId>

          <artifactId>javaee-api</artifactId>

          <version>7.0</version>

        </dependency>

        <!-- 导入Mysql数据库链接jar包 -->

        <dependency>

          <groupId>mysql</groupId>

          <artifactId>mysql-connector-java</artifactId>

          <version>5.1.30</version>

        </dependency>

        <!-- 导入dbcp的jar包,用来在applicationContext.xml中配置数据库 -->

        <dependency>

          <groupId>commons-dbcp</groupId>

          <artifactId>commons-dbcp</artifactId>

          <version>1.2.2</version>

        </dependency>

        <!-- JSTL标签类 -->

        <dependency>

          <groupId>jstl</groupId>

          <artifactId>jstl</artifactId>

          <version>1.2</version>

        </dependency>

        <!-- 日志文件管理包 -->

        <!-- log start -->

        <dependency>

          <groupId>log4j</groupId>

          <artifactId>log4j</artifactId>

          <version>${log4j.version}</version>

        </dependency>



        <!-- 格式化对象,方便输出日志 -->

        <dependency>

          <groupId>com.alibaba</groupId>

          <artifactId>fastjson</artifactId>

          <version>1.1.41</version>

        </dependency>



        <dependency>

          <groupId>org.slf4j</groupId>

          <artifactId>slf4j-api</artifactId>

          <version>${slf4j.version}</version>

        </dependency>


        <dependency>

          <groupId>org.slf4j</groupId>

          <artifactId>slf4j-log4j12</artifactId>

          <version>${slf4j.version}</version>

        </dependency>

        <!-- log end -->

        <!-- 映入JSON -->

        <dependency>

          <groupId>org.codehaus.jackson</groupId>

          <artifactId>jackson-mapper-asl</artifactId>

          <version>1.9.13</version>

        </dependency>

        <!-- 上传组件包 -->

        <dependency>

          <groupId>commons-fileupload</groupId>

          <artifactId>commons-fileupload</artifactId>

          <version>1.3.1</version>

        </dependency>

        <dependency>

          <groupId>commons-io</groupId>

          <artifactId>commons-io</artifactId>

          <version>2.4</version>

        </dependency>

        <dependency>

          <groupId>commons-codec</groupId>

          <artifactId>commons-codec</artifactId>

          <version>1.9</version>

        </dependency>


        <!-- druid -->

        <dependency>

          <groupId>com.alibaba</groupId>

          <artifactId>druid</artifactId>

          <version>0.2.9</version>

        </dependency>



        <!-- aspectjweaver.jar这是Spring AOP所要用到的包 -->

        <dependency>

          <groupId>org.aspectj</groupId>

          <artifactId>aspectjweaver</artifactId>

          <version>1.7.1</version>

        </dependency>



        <dependency>

          <groupId>org.springframework</groupId>

          <artifactId>spring-orm</artifactId>

          <version>3.2.0.RELEASE</version>

        </dependency>


        <!-- hibernate4 -->

        <dependency>

          <groupId>org.hibernate</groupId>

          <artifactId>hibernate-core</artifactId>

          <version>4.2.5.Final</version>

        </dependency>

        <dependency>

          <groupId>org.hibernate</groupId>

          <artifactId>hibernate-entitymanager</artifactId>

          <version>4.2.5.Final</version>

        </dependency>

        <dependency>

          <groupId>org.hibernate</groupId>

          <artifactId>hibernate-ehcache</artifactId>

          <version>4.2.5.Final</version>

        </dependency>

        <dependency>

          <groupId>org.hibernate.javax.persistence</groupId>

          <artifactId>hibernate-jpa-2.0-api</artifactId>

          <version>1.0.1.Final</version>

        </dependency>

        <!--验证码-->

        <dependency>

          <groupId>com.github.penggle</groupId>

          <artifactId>kaptcha</artifactId>

          <version>2.3.2</version>

        </dependency>

        <dependency>

          <groupId>junit</groupId>

          <artifactId>junit</artifactId>

          <version>4.11</version>

        </dependency>


        <!-- jackson start -->

        <dependency>

          <groupId>org.codehaus.jackson</groupId>

          <artifactId>jackson-core-asl</artifactId>

          <version>1.9.12</version>

        </dependency>

          <dependency>

              <groupId>com.fasterxml.jackson.core</groupId>

              <artifactId>jackson-core</artifactId>

              <version>2.7.4</version>

          </dependency>

        <dependency>

          <groupId>com.fasterxml.jackson.core</groupId>

          <artifactId>jackson-annotations</artifactId>

          <version>2.7.4</version>

        </dependency>

          <dependency>

              <groupId>com.fasterxml.jackson.core</groupId>

              <artifactId>jackson-databind</artifactId>

              <version>2.7.4</version>

          </dependency>

        <dependency>

          <groupId>org.codehaus.jackson</groupId>

          <artifactId>jackson-mapper-lgpl</artifactId>

          <version>1.9.12</version>

        </dependency>


        <!-- http://mvnrepository.com/artifact/commons-io/commons-io -->

        <dependency>

          <groupId>commons-io</groupId>

          <artifactId>commons-io</artifactId>

          <version>2.4</version>

        </dependency>


        <!-- http://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->

        <dependency>

          <groupId>commons-fileupload</groupId>

          <artifactId>commons-fileupload</artifactId>

          <version>1.3.1</version>

        </dependency>



      </dependencies>


      <build>

        <finalName>educationcrm</finalName>

        <plugins>

          <plugin>

            <groupId>org.apache.maven.plugins</groupId>

            <artifactId>maven-compiler-plugin</artifactId>

            <configuration>

              <source>1.8</source>

              <target>1.8</target>

            </configuration>

          </plugin>

        </plugins>

      </build>

    </project>

    这个是我的pom文件,主要使用的spring,springmvc,hibernate

    <dependency>

    中间就是需要的jar包和jar版本号

    </dependency>


    具体需要什么jar包去 http://mvnrepository.com/  这个网站就是maven的jar仓库


  • qq_向往巴哈伊_03998691
    2016-09-17 19:22:38

    我也想知道从哪儿copy的

  • 小杨小宇
    2016-06-09 15:15:56

    COPY都不会还学什么?