2

In my current project I'm using spring boot i want to exclude all dependencies.

<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>1.3.3.RELEASE</version> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> <configuration> <mainClass>a.b.testClass</mainClass> <layout>ZIP</layout> <excludeArtifactIds>*</excludeArtifactIds> </configuration> </plugin> 
2
  • If you do that then it won't work. Commented Apr 7, 2016 at 12:47
  • Why do you want to do that... That basically beats the purpose of even using Spring Boot. Commented Apr 7, 2016 at 12:57

2 Answers 2

2

Ugly solution that seems to work is to put includes with not existing artifact:

<configuration> <layout>ZIP</layout> <includes> <include> <groupId>abc</groupId> <artifactId>abc</artifactId> </include> </includes> </configuration> 

Works on version 1.3.3 but there is not guarantee it won't change in next versions.

Or, you can package everything yourself, there are instructions for ant: http://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html#howto-build-an-executable-archive-with-ant that can give you list of steps that you need to apply in maven. So:

  1. Include Main Class and Start Class in manifest:

    <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>org.springframework.boot.loader.PropertiesLauncher</mainClass> </manifest> <manifestEntries> <Start-Class>your.package.YourMainClass</Start-Class> </manifestEntries> </archive> </configuration> </plugin> 
  2. Skip adding dependencies in lib directory.

  3. Add spring boot loader classes to the root: First you need dependency:

    <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-loader</artifactId> <version>1.3.3.RELEASE</version> </dependency> 

    Then you need to unpack it:

    <plugin> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <phase>process-sources</phase> <goals> <goal>unpack</goal> </goals> <configuration> <artifactItems> <artifactItem> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-loader</artifactId> <outputDirectory>${project.build.directory}/classes</outputDirectory> </artifactItem> </artifactItems> </configuration> </execution> </executions> </plugin> 

    There might be a better way to put loader classes in root, but this works ok for my project.

Sign up to request clarification or add additional context in comments.

Comments

-1

You can try this one.

<configuration> <excludes> <exclude> <groupId>*</groupId> <artifactId>*</artifactId> </exclude> </excludes> </configuration> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.