原 《intellij idea maven 依賴 部署 》 解決方案

針對以前本身的一篇 博客 《intellij idea maven 依賴 部署》實現的解決方案以下:java

在每個子模塊的pom.xml 文件中指定父級模塊,並指定相對應的依賴模塊mysql

新項目結構:web

Base 模塊pom.xmlspring

<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">
    <parent>
        <artifactId>prjDyOnline</artifactId>
        <groupId>prjDyOnline</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>Base</artifactId>
    <name>Base </name>
    <url>http://maven.apache.org</url>
    <build>
        <finalName>Base</finalName>
    </build>
</project>

  Common 模塊pom.xmlsql

<?xml version="1.0" encoding="UTF-8"?>
<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">
    <parent>
        <artifactId>prjDyOnline</artifactId>
        <groupId>prjDyOnline</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>Common</artifactId>
    <name>Common </name>
    <url>http://maven.apache.org</url>
    <build>
        <finalName>Common</finalName>
    </build>

</project>

Helper 模塊pom.xml
apache

<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">
    <parent>
        <artifactId>prjDyOnline</artifactId>
        <groupId>prjDyOnline</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>Helper</artifactId>
    <name>Helper </name>
    <url>http://maven.apache.org</url>
    <dependencies>
    <dependency>
        <groupId>prjDyOnline</groupId>
        <artifactId>Common</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>prjDyOnline</groupId>
        <artifactId>Model</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
        <dependency>
            <groupId>prjDyOnline</groupId>
            <artifactId>Tools</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>Helper</finalName>
    </build>
</project>

Model 模塊pom.xml
api

<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">
    <parent>
        <artifactId>prjDyOnline</artifactId>
        <groupId>prjDyOnline</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>Model</artifactId>
    <name>Model</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
            <groupId>prjDyOnline</groupId>
            <artifactId>Base</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>prjDyOnline</groupId>
            <artifactId>Tools</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>Model</finalName>
    </build>
</project>

 Service 模塊pom.xmltomcat

<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">
    <parent>
        <artifactId>prjDyOnline</artifactId>
        <groupId>prjDyOnline</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>Service</artifactId>
    <name>Service</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
            <groupId>prjDyOnline</groupId>
            <artifactId>Model</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
</project>

Tools 模塊pom.xml
mybatis

<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">
    <parent>
        <artifactId>prjDyOnline</artifactId>
        <groupId>prjDyOnline</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>Tools</artifactId>
    <name>Tools </name>
    <url>http://maven.apache.org</url>

    <dependencies>
        <dependency>
            <groupId>prjDyOnline</groupId>
            <artifactId>Common</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>Tools</finalName>
    </build>
</project>

 Web 模塊pom.xmlmvc

<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">
    <parent>
        <artifactId>prjDyOnline</artifactId>
        <groupId>prjDyOnline</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>Web</artifactId>
    <packaging>war</packaging>
    <name>Web Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
            <groupId>prjDyOnline</groupId>
            <artifactId>Service</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
         <dependency>
            <groupId>prjDyOnline</groupId>
            <artifactId>Helper</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>Web</finalName>
    </build>
</project>

主項目模塊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>prjDyOnline</groupId>
  <artifactId>prjDyOnline</artifactId>
  <packaging>pom</packaging>
  <version>1.0-SNAPSHOT</version>
    <properties>
        <spring-version>4.0.3.RELEASE</spring-version>
        <tomcat-jdbc-version>8.0.5</tomcat-jdbc-version>
        <mybatis-version>3.2.6</mybatis-version>
        <jackson-version>2.4.0-rc1</jackson-version>
    </properties>
    <modules>
        <module>Base</module>
        <module>Common</module>
        <module>Model</module>
        <module>Helper</module>
        <module>Tools</module>
        <module>Service</module>
        <module>Web</module>
    </modules>
    <name>prjDyOnline</name>
  <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</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-test</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-context-support</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>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-jdbc</artifactId>
            <version>${tomcat-jdbc-version}</version>
        </dependency>
        <dependency>
            <groupId>commons-configuration</groupId>
            <artifactId>commons-configuration</artifactId>
            <version>1.7</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-juli</artifactId>
            <version>${tomcat-jdbc-version}</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>${mybatis-version}</version>
        </dependency>
        <dependency>
            <groupId>nl.bitwalker</groupId>
            <artifactId>UserAgentUtils</artifactId>
            <version>1.2.4</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.30</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>1.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.3.1</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</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>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>${jackson-version}</version>
        </dependency>
        <dependency>
            <groupId>tomcat</groupId>
            <artifactId>jsp-api</artifactId>
            <version>5.5.23</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>tomcat</groupId>
            <artifactId>servlet-api</artifactId>
            <version>5.5.23</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
			<version>1.7.7</version>
		</dependency>
      	<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
			<version>1.7.7</version>
		</dependency>
        <dependency>
            <groupId>com.belerweb</groupId>
            <artifactId>pinyin4j</artifactId>
            <version>2.5.0</version>
        </dependency>
        <dependency>
            <groupId>dycore</groupId>
            <artifactId>dy-webplus</artifactId>
            <version>1.0.14</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.mobile</groupId>
            <artifactId>spring-mobile-device</artifactId>
            <version>1.1.2.RELEASE</version>
        </dependency>
    </dependencies>
  <build>
    <finalName>prjDyOnline</finalName>
      <plugins>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-surefire-plugin</artifactId>
              <configuration>
                  <testFailureIgnore>true</testFailureIgnore>
              </configuration>
          </plugin>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <configuration>
                  <source>7</source>
                  <target>7</target>
                  <encoding>UTF-8</encoding>
              </configuration>
          </plugin>
      </plugins>
  </build>

</project>

 這個時候,編譯web 項目的時候,能夠單獨的在web模塊下面進行maven 的install 進行打war包,其餘的子模塊會以jar包的形式存在。

用idea 的tomcat 啓動的時候,直接單獨的執行web 的模塊就能夠啦

over

相關文章
相關標籤/搜索