I am reading spring-boot doc and there they said that
To create an executable jar we need to add the spring-boot-maven-plugin to our pom.xml. Insert the following lines just below the dependencies section
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Following are my main pom which includes other module
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.5.RELEASE</version>
</parent>
<groupId>de.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<description>demo</description>
<properties>
<java.version>1.6</java.version>
<joda.version>2.5</joda.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- joda time -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${joda.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<modules>
<module>db</module>
<module>web</module>
</modules>
following is the db
<parent>
<groupId>de.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>db<artifactId>
<description>demo</description>
<dependencyManagement>
<dependencies>
<!-- spring data jpa -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
<!-- hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</dependency>
</dependencies>
</dependencyManagement>
following is web
<parent>
<groupId>de.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>web</artifactId>
<dependencyManagement>
<dependency>
<groupId>com.example</groupId>
<artifactId>db</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencyManagement>
I have created multi-module project. I am using spring boot parent. In any of my modules pom I do not have above plugin but still it create jar file in target folder after I run following command on web module as base directory
mvn clean install spring-boot:run
I am missing any thing to understand. Please do comment.
Maven uses maven-jar-plugin to build a non executable jar
file and spring-boot-maven-plugin is used to create an executable jar.
In you case even though you do not specify the spring-boot-maven-plugin
, the maven-jar-plugin
will create the jar
file.
You can check this when you do a mvn install
and see the build logs.