If you use a Maven build that inherits from spring-boot-starter-parent
but you want
to override a specific third-party dependency you can add appropriate <properties>
elements. Browse the spring-dependencies
POM for a complete list of properties. For example, to pick a different slf4j
version
you would add the following:
<properties> <slf4j.version>1.7.5<slf4j.version> </properties>
Warning | |
---|---|
Each Spring Boot release is designed and tested against a specific set of third-party dependencies. Overriding versions may cause compatibility issues. |
The spring-boot-maven-plugin
can be used to create an executable “fat” JAR. If you
are using the spring-boot-starter-parent
POM you can simply declare the plugin and
your jars will be repackaged:
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
If you are not using the parent POM you can still use the plugin, however, you must
additionally add an <executions>
section:
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>1.1.0.RC1</version> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
See the plugin documentation for full usage details.
To attach a remote debugger to a Spring Boot application started with Maven you can use
the mvnDebug
command rather than mvn
. For example:
$ mvnDebug spring-boot:run
You can now attach a remote debugger to your running application on port 8000
.
To build with Ant you need to grab dependencies, compile and then create a jar or war archive as normal. To make it executable:
Main-Class
, e.g. JarLauncher
for a jar file, and
specify the other properties it needs as manifest entries, principally a Start-Class
.
provided
(embedded container) dependencies in a nested lib-provided
directory.
Remember not to compress the entries in the archive.
spring-boot-loader
classes at the root of the archive (so the Main-Class
is available).
Example:
<target name="build" depends="compile"> <copy todir="target/classes/lib"> <fileset dir="lib/runtime" /> </copy> <jar destfile="target/spring-boot-sample-actuator-${spring-boot.version}.jar" compress="false"> <fileset dir="target/classes" /> <fileset dir="src/main/resources" /> <zipfileset src="lib/loader/spring-boot-loader-jar-${spring-boot.version}.jar" /> <manifest> <attribute name="Main-Class" value="org.springframework.boot.loader.JarLauncher" /> <attribute name="Start-Class" value="${start-class}" /> </manifest> </jar> </target>
The Actuator Sample has a build.xml
that should work if you run it with
$ ant -lib <path_to>/ivy-2.2.jar
after which you can run the application with
$ java -jar target/*.jar