Archive

Archive for December, 2012

Maven-Eclipse-Spring Integration

December 27, 2012 2 comments

In every new project I write I use maven and Eclipse. On most of these projects I use Spring as well – and I’m probably not the only one around doing it.

The problem I always run in to is how to configure everything to work properly – so once I finally got a properly working configuration, I had to write it down:

Simple Configuration – Maven + Eclipse
This configuration in your pom.xml will generate your .project and .classpath files (and a few more).

<plugin>
	<artifactId>maven-eclipse-plugin</artifactId>
	<version>2.9</version>
</plugin>

Slightly Advanced Configuration – Maven + Eclipse
This configuration will also automatically download sources and javadocs of any dependency you add into your project – very useful when working with open source software.

<plugin>
	<artifactId>maven-eclipse-plugin</artifactId>
	<version>2.9</version>
	<configuration>
		<downloadSources>true</downloadSources>
		<downloadJavadocs>true</downloadJavadocs>
	</configuration>
</plugin>

Spring Specific Configuration – Add Support in Eclipse
The additionalProjectnatures and additionalBuildcommands sections add the springnature and springbuilder to the project and allow you to get Spring specific highlights and notifications on your project (e.g. Icons on each class indicating if it is a Spring bean)

<plugin>
	<artifactId>maven-eclipse-plugin</artifactId>
	<version>2.9</version>
	<configuration>
		<additionalProjectnatures>
			<projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
		</additionalProjectnatures>
		<additionalBuildcommands>
			<buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
		</additionalBuildcommands>
		<downloadSources>true</downloadSources>
		<downloadJavadocs>true</downloadJavadocs>
	</configuration>
</plugin>

The Maven-Eclipse Plugin has a few more configurations and abilities, you can read more about it on http://maven.apache.org/plugins/maven-eclipse-plugin/