maven 项目拆分配置文件为单独的项目

SailLiao 发布于 2016/10/21 13:09
阅读 1K+
收藏 0

想将项目的配置文件拆分为单独的配置文件的项目,一直都不行。

这是父项目

这是 配置文件的项目

这是resources项目的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>

	<parent>
		<groupId>com.lzf</groupId>
		<artifactId>web-base</artifactId>
		<version>0.1</version>
	</parent>

	<artifactId>web-resources</artifactId>
	<packaging>war</packaging>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-war-plugin</artifactId>
				<version>2.6</version>
				<configuration>
					<failOnMissingWebXml>false</failOnMissingWebXml>
				</configuration>
			</plugin>
		</plugins>
		<resources>
			<resource>
				<directory>src/main/java</directory>
				<includes>
					<include>**/*.properties</include>
					<include>**/*.xml</include>
				</includes>
				<filtering>false</filtering>
			</resource>
			<resource>
				<directory>src/main/resources</directory>
				<includes>
					<include>**/*.properties</include>
					<include>**/*.xml</include>
				</includes>
				<filtering>false</filtering>
			</resource>
		</resources>
	</build>


</project>



这是 web 的项目

这是web项目的 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>

	<parent>
		<groupId>com.lzf</groupId>
		<artifactId>web-base</artifactId>
		<version>0.1</version>
	</parent>

	<artifactId>web</artifactId>

	<dependencies>

		<dependency>
			<groupId>com.lzf</groupId>
			<artifactId>web-resources</artifactId>
			<version>0.1</version>
		</dependency>

		<!-- javax -->
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>javax.servlet-api</artifactId>
			<version>3.1.0</version>
		</dependency>
		<dependency>
			<groupId>javax.servlet.jsp.jstl</groupId>
			<artifactId>javax.servlet.jsp.jstl-api</artifactId>
			<version>1.2.1</version>
		</dependency>


		<!-- spring mvc -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>4.1.0.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-orm</artifactId>
			<version>4.1.0.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</artifactId>
			<version>4.1.0.RELEASE</version>
		</dependency>

		<!-- others -->
		<dependency>
			<groupId>commons-fileupload</groupId>
			<artifactId>commons-fileupload</artifactId>
			<version>1.3.1</version>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit-dep</artifactId>
			<version>4.11</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-lang3</artifactId>
			<version>3.3.2</version>
		</dependency>

		<!-- log4j -->
		<dependency>
			<groupId>log4j</groupId>
			<artifactId>log4j</artifactId>
			<version>1.2.17</version>
		</dependency>

		<!-- jstl -->
		<dependency>
			<groupId>jstl</groupId>
			<artifactId>jstl</artifactId>
			<version>1.1.2</version>
		</dependency>

		<!-- taglibs -->
		<dependency>
			<groupId>taglibs</groupId>
			<artifactId>standard</artifactId>
			<version>1.1.2</version>
		</dependency>

		<!-- dubbo -->
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>dubbo</artifactId>
			<version>2.5.3</version>
			<exclusions>
				<exclusion>
					<groupId>org.springframework</groupId>
					<artifactId>spring</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

		<!-- zkclient -->
		<dependency>
			<groupId>com.github.sgroschupf</groupId>
			<artifactId>zkclient</artifactId>
			<version>0.1</version>
		</dependency>

		<!-- zookeeper -->
		<dependency>
			<groupId>org.apache.zookeeper</groupId>
			<artifactId>zookeeper</artifactId>
			<version>3.4.9</version>
		</dependency>

	</dependencies>

</project>



项目发布到tomcat 没有配置文件。


加载中
0
Allen_Ho
Allen_Ho

结构有点问题吧?可以试试这样做,定义三个工程:

1.parent.pom 其中要求是<packaging>pom</packaging>,里面包含两个模块

<modules>
  <module>web-resources</module>
  <module>web-base</module>
  </modules>
2.web-resources 这个工程就是你的资源项目
3.web-base 这个工程pom里面依赖web-resources,然后<packaging>war</packaging>

Project分模块的话,一般这样做,不过为什么要把资源文件单独一个工程出来?我觉得一些对外接口还有common之类的才有必要单独模块出来

Kevin_Zhan
Kevin_Zhan
公共的配置文件也是需要独立出来,不可能数据库,redis,dubbo等一样的配置文件每个项目都复制一份
SailLiao
SailLiao
好的,我试试,非常感谢。
0
小豪哥哥丶
可以体验一下魔方网表试试
0
Kevin_Zhan
Kevin_Zhan
请问解决了?我这个也是找不到另一个项目的配置
返回顶部
顶部