• 使用eclipse搭建maven多module项目(构建父子项目)


    创建空maven项目

    1. File–>new–>project… 

    2.next

    3.next

    4.finish

    5.配置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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>pdd-shop</groupId>
    <artifactId>pdd-shop</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>pdd-shop</name>
    <url>http://maven.apache.org</url>
    <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <junit.version>4.11</junit.version>
    <spring.version>4.0.0.RELEASE</spring.version>
    </properties>
    <build>
    <finalName>pdd-shop</finalName>
    <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
    <source>1.6</source>
    <target>1.6</target>
    <compilerVersion>1.6</compilerVersion>
    </configuration>
    </plugin>
    <!-- jar插件 -->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.5</version>
    <configuration>
    <archive>
    <manifest>
    <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
    <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
    </manifest>
    </archive>
    </configuration>
    </plugin>
    </plugins>
    </build>
    <dependencies>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>${junit.version}</version>
    </dependency>
    <!-- spring framework -->
    <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-logging</groupId>
    <artifactId>commons-logging</artifactId>
    <version>1.2</version>
    </dependency>
    </dependencies>
    <modules>
    <module>pdd-shop-application</module>
    <module>pdd-shop-appweb</module>
    <module>pdd-shop-application-impl</module>
    </modules>
    </project>

    创建module

    创建java module

    1. 右键ppd-shop项目–>new–>project… 

    2.next

    3.next

    4.next

    5.finish–>配置pom.xml 
    (主要把多余部分删除,junit只要在父工程的pom配置就可以了)

    <?xml version="1.0"?>
    <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <parent>
    <artifactId>pdd-shop</artifactId>
    <groupId>pdd-shop</groupId>
    <version>0.0.1-SNAPSHOT</version>
    </parent>
    <groupId>pdd-shop</groupId>
    <artifactId>pdd-shop-application</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>pdd-shop-application</name>
    </project>

    创建web module

    1. 与创建java module的1、2点一样;

    2. next 

    3.把包名定义下~

    4.右键pdd-shop-appweb项目–>properties–>Project Facets–>Convert to faceted form.. 
    这里选2.4版本的web工程是因为楼主用的是tomcat 6.0啦,按自己实际情况去修改 

    5.配置pom.xml 
    配置中有两点说明下:1、把jar包自动拷贝到web-inf目录地下,这个搞web开发都懂是为什么了;2、配置子项目依赖

    <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <parent>
    <artifactId>pdd-shop</artifactId>
    <groupId>pdd-shop</groupId>
    <version>0.0.1-SNAPSHOT</version>
    </parent>
    <groupId>pdd-shop</groupId>
    <artifactId>pdd-shop-appweb</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>pdd-shop-appweb Maven Webapp</name>
    <build>
    <finalName>pdd-shop-appweb</finalName>
    <plugins>
    <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
    <execution>
    <id>copy-lib-src-webapps</id>
    <phase>package</phase>
    <configuration>
    <tasks>
    <delete dir="WebContent/WEB-INF/lib" />
    <copy todir="WebContent/WEB-INF/lib">
    <fileset dir="target/${artifactId}/WEB-INF/lib">
    <include name="*" />
    </fileset>
    </copy>
    </tasks>
    </configuration>
    <goals>
    <goal>run</goal>
    </goals>
    </execution>
    </executions>
    </plugin>
    </plugins>
    </build>
    <dependencies>
    <dependency>
    <groupId>${groupId}</groupId>
    <artifactId>pdd-shop-application-impl</artifactId>
    <version>${version}</version>
    </dependency>
    </dependencies>
    </project>

    项目依赖

    扩展

  • 相关阅读:
    CF1063A Oh Those Palindromes
    洛谷——P1640 [SCOI2010]连续攻击游戏
    洛谷—— P1268 树的重量
    洛谷——P4932 浏览器
    洛谷——P1627 [CQOI2009]中位数
    洛谷——P4109 [HEOI2015]定价
    CF438D The Child and Sequence
    AFO
    About me & 留言板
    The real universe
  • 原文地址:https://www.cnblogs.com/austinspark-jessylu/p/7053018.html
Copyright © 2020-2023  润新知