我把属性在我的Maven的pom.xml。首先,我砍掉了整个网络应用程序,以便为不同的图层提供单独的罐子; persistenc/db,service,web(例如,用于spring mvc的控制器)和war。战争项目在src/main/resources中包含jsps和properties/config/xml文件。
例如,我的父POM开始是这样的:
<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>edu.berkeley.ist.waitlist</groupId>
<artifactId>waitlist-parent</artifactId>
<modules>
<module>../waitlist-core</module>
<module>../waitlist-db</module>
<module>../waitlist-web</module>
<module>../waitlist-war</module>
<module>../waitlistd</module>
</modules>
和
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/hbm</directory>
<filtering>true</filtering>
</resource>
</resources>
和
<dependencyManagement>
<!-- dependencies with exclusions -->
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${version.springframework}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
然后我有一大堆的配置文件,为各种构建:
<profiles>
<!-- ========================================================== -->
<!-- local, hsql -->
<!-- ========================================================== -->
<profile>
<id>localhost-hsql</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<!-- need to specify ${basedir} so that hsql creates its files in the right place -->
<db2.url>jdbc:hsqldb:file:${basedir}/target/waitlistv2;shutdown=true</db2.url>
<db2.user>sa</db2.user>
<db2.password />
<jdbc-db2.driverClass>org.hsqldb.jdbcDriver</jdbc-db2.driverClass>
<db2.schema>public</db2.schema>
<db2.hibernate.default_schema>public</db2.hibernate.default_schema>
<db2.hibernate.dialect>org.hibernate.dialect.HSQLDialect</db2.hibernate.dialect>
<dbunit.dataTypeFactoryName>org.dbunit.ext.hsqldb.HsqldbDataTypeFactory</dbunit.dataTypeFactoryName>
<hbmtool.haltOnError>false</hbmtool.haltOnError>
<log.filename>/tmp/waitlist.log</log.filename>
</properties>
</profile>
例如,在等候名单战/ src目录/主/资源是文件logback.xml,并将其与
<configuration debug="true">
<appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="RootFileAppender">
<!-- set in the pom.xml file -->
<file>${log.filename}</file>
开始所以,你可以看到从POM中的log.filename属性用于因到maven的过滤。 (我指定了父类的所有版本,并且子项目只是指定了它们使用的依赖关系,但没有版本号,我不确定这是否是正确的方法,最佳实践等等。
此外,waitlist-war取决于waitlist-web,waitlist-web取决于waitlist-core(我的服务层),而waitlist-core取决于waitlist-db。Waitlistd是一个独立的应用程序,
我还没有机会使用这种方法还,但它听起来很合理,发言,它依赖于申请人名单芯)。我也非常喜欢它在链接到的演示文稿中的概述(加上它还有很多其他好的信息),所以非常感谢! – 2009-07-31 17:52:07