Configure a java spring project built by maven -


i have java spring web project. divided several maven modules , projects. currently, each artifact has application-context.xml , default.properties (so each project runnable independantly.) use annotation-based bean creation , @value annotations properties.

the aggregating webapp project has (of course) pom , property files each build target.

my problem now: feeld little chaotic. pom has several profiles, 1 each build server, , contains properties needed maven @ build time (target server url) or properties have replaced in config files (log4j smtp host). then, have property file each build system wheren use ${maven.variables} , overwrite default variables included artifacts (like database, email config, etc).

the properties grew on time many aspects different between live , test server. difficult new developers in project set project, although should use kind of dev-default + db credentials.

how handle properties build/runtime?

edit: thing annoys me: properties can't validated (if exist, finding typos time consuming task...) currently. maybere there solution it?

not sure how maven project setup build environment use maven resource plugin projects.

project structure (standard maven structure)

/project -/src --/filters ---/filter.dev.properties ---/filter.test.properties --/java --/resources ---/config.properties pom.xml 

the config.properties (or other app config files) used app code configure itself. have filter files each environment holds environment specific value , these replace placeholders in config.properties

my pom file

<build>     <plugins>         <plugin>             <artifactid>maven-compiler-plugin</artifactid>             <configuration>                 <source>1.6</source>                 <target>1.6</target>             </configuration>         </plugin>     </plugins>     <filters>         <filter>src/main/filters/filter.${env}.properties</filter>     </filters>     <resources>         <resource>             <directory>src/main/resources</directory>             <filtering>true</filtering>             <includes>                 <include>**/*.properties</include>             </includes>         </resource>     </resources> </build> <profiles>     <profile>         <id>dev</id>         <activation>             <activebydefault>true</activebydefault>         </activation>         <properties>             <env>dev</env>         </properties>     </profile>     <profile>         <id>test</id>         <properties>             <env>test</env>         </properties>     </profile> </profiles>  

be default when build locally don't provide profile maven, use filter.dev.properties, building test environment, in jenkins job use test profile.


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -