spring:load

Full name:

org.kuali.maven.plugins:spring-maven-plugin:1.1.5-SNAPSHOT:load

Description:

Load a Spring context XML file optionally filtering it using Maven properties before doing so. If exportProperties is true, Maven properties are exported to the file system prior to loading and filtering the Spring context. The path to the exported properties file is automatically added to the Maven properties under the key maven.spring.properties. This combination makes it simple to inject the complete set of Maven properties into a Spring context.

One method for doing so, is to include this configuration in a Maven pom:
<plugin>
  <groupId>org.kuali.maven.plugins</groupId>
  <artifactId>spring-maven-plugin</artifactId>
  <configuration>
    <filterContext>true</filterContext>
    <filterInclude>maven.spring.properties</filterInclude>
    <contextLocation>classpath:my-context.xml</contextLocation>
  </configuration>
</plugin>
and then include this configuration in a Spring context XML file:
<context:property-placeholder location="${maven.spring.properties}" />
Using this configuration, mvn spring:load will filter my-context.xml replacing ${maven.spring.properties} with the location of the properties file Maven properties were exported to. When the Spring context is loaded, Maven properties will be used to perform placeholder substitution. This makes it possible to easily take advantage of Maven configuration like project.artifactId in the Spring context.

For example:
  <bean id="artifactId" class="java.lang.String">
    <constructor-arg value="${project.artifactId}" />
  </bean>

Attributes:

  • Requires a Maven project to be executed.

Required Parameters

Name Type Since Description
contextLocation String - Location of a Spring context XML file. This can be any URL Spring's Resource loading framework understands eg classpath:my-context.xml
Default value is: classpath:${project.artifactId}-context.xml.
serviceClassname String - The implementation of org.kuali.common.util.service.SpringService to use
Default value is: org.kuali.common.util.service.DefaultSpringService.

Optional Parameters

Name Type Since Description
encoding String - Character encoding for the context XML file
Default value is: ${project.build.sourceEncoding}.
exportExclude String - Comma separated list of properties to exclude from the export
exportExcludes List - List of properties to exclude. No properties are excluded by default.
exportInclude String - Comma separated list of properties to include in the export
exportIncludes List - List of properties to include. All properties are included by default.
exportProperties boolean - If true, Maven properties are exported to the file system prior to filtering and loading the Spring context.
Default value is: false.
exportPropertiesFile File - The file to export properties to when exportProperties is true
Default value is: ${project.build.directory}/spring/maven.properties.
exportPropertiesFileProperty String - If exportProperties is true, the path to the exported properties file will be included as a property under this key
Default value is: maven.spring.properties.
filterContext boolean - If true contextLocation is filtered before being loaded
Default value is: false.
filterExclude String - Comma separated list of properties to exclude when filtering the context
filterExcludes List - List of properties to exclude. No properties are excluded by default.
filterInclude String - Comma separated list of properties to include when filtering the context
filterIncludes List - List of properties to include. All properties are included by default.
properties Properties - Additional properties to supply to the Spring context. Properties provided here are added to Maven properties.
workingDir File - Working directory for the plugin.
Default value is: ${project.build.directory}/spring.

Parameter Details

contextLocation:

Location of a Spring context XML file. This can be any URL Spring's Resource loading framework understands eg classpath:my-context.xml
  • Type: java.lang.String
  • Required: Yes
  • Expression: ${spring.contextLocation}
  • Default: classpath:${project.artifactId}-context.xml

encoding:

Character encoding for the context XML file
  • Type: java.lang.String
  • Required: No
  • Expression: ${spring.encoding}
  • Default: ${project.build.sourceEncoding}

exportExclude:

Comma separated list of properties to exclude from the export
  • Type: java.lang.String
  • Required: No
  • Expression: ${spring.exportExclude}

exportExcludes:

List of properties to exclude. No properties are excluded by default.
  • Type: java.util.List
  • Required: No

exportInclude:

Comma separated list of properties to include in the export
  • Type: java.lang.String
  • Required: No
  • Expression: ${spring.exportInclude}

exportIncludes:

List of properties to include. All properties are included by default.
  • Type: java.util.List
  • Required: No

exportProperties:

If true, Maven properties are exported to the file system prior to filtering and loading the Spring context.
  • Type: boolean
  • Required: No
  • Expression: ${spring.exportProperties}
  • Default: false

exportPropertiesFile:

The file to export properties to when exportProperties is true
  • Type: java.io.File
  • Required: No
  • Expression: ${spring.exportPropertiesFile}
  • Default: ${project.build.directory}/spring/maven.properties

exportPropertiesFileProperty:

If exportProperties is true, the path to the exported properties file will be included as a property under this key
  • Type: java.lang.String
  • Required: No
  • Expression: ${spring.exportPropertiesFileProperty}
  • Default: maven.spring.properties

filterContext:

If true contextLocation is filtered before being loaded
  • Type: boolean
  • Required: No
  • Expression: ${spring.filterContext}
  • Default: false

filterExclude:

Comma separated list of properties to exclude when filtering the context
  • Type: java.lang.String
  • Required: No
  • Expression: ${spring.filterExclude}

filterExcludes:

List of properties to exclude. No properties are excluded by default.
  • Type: java.util.List
  • Required: No

filterInclude:

Comma separated list of properties to include when filtering the context
  • Type: java.lang.String
  • Required: No
  • Expression: ${spring.filterInclude}

filterIncludes:

List of properties to include. All properties are included by default.
  • Type: java.util.List
  • Required: No

properties:

Additional properties to supply to the Spring context. Properties provided here are added to Maven properties.
  • Type: java.util.Properties
  • Required: No

serviceClassname:

The implementation of org.kuali.common.util.service.SpringService to use
  • Type: java.lang.String
  • Required: Yes
  • Expression: ${spring.serviceClassname}
  • Default: org.kuali.common.util.service.DefaultSpringService

workingDir:

Working directory for the plugin.
  • Type: java.io.File
  • Required: No
  • Expression: ${spring.workingDir}
  • Default: ${project.build.directory}/spring