I have a multimodule project, build with spring boot 1.1.7
The structure is
+ parent
+ import
+ web
+ backend
My Parent Module will include kind of microservices, what I want to manage from my parent (dependencies what all use) and so on. In import/backend there is my batch business logic, in web there is a mvc application, from where I can start batch job.
In Eclipse everything works fine for me, I can start the application from the Application.java file and application works.
Now I wanted to execute that application by executing executable jar file, but I get following error message when try starting from console.
java -jar application.jar
Kein Hauptmanifestattribut in application.jar
The jar is very small only 5kb, I didn't find any jars of 3 party dependencies in jar package.
The Pom of Web-Module is like follows:
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>at.company.bbsng</groupId>
<artifactId>bbsng-import</artifactId>
<version>0.1.0-SNAPSHOT</version>
</parent>
<artifactId>bbsng-import-web</artifactId>
<name>bbsng-import-web</name>
<packaging>jar</packaging>
<properties>
<start-class>at.company.bbsng.dataimport.Application</start-class>
</properties>
<dependencies>
<!-- APPLICATION -->
<dependency>
<groupId>at.company.bbsng</groupId>
<artifactId>bbsng-import-backend</artifactId>
<version>${parent.version}</version>
</dependency>
<!-- SPRING ... -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-logging</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
...
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Pom of Import Module is:
<project>
<parent>
<groupId>at.company.bbsng</groupId>
<artifactId>bbsng</artifactId>
<version>0.1.0-SNAPSHOT</version>
</parent>
<artifactId>bbsng-import</artifactId>
<name>bbsng-import</name>
<packaging>pom</packaging>
<modules>
<module>backend</module>
<module>web</module>
</modules>
</project>
And Pom of Parent is:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>at.company.bbsng</groupId>
<artifactId>bbsng</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>bbsng</name>
<description>BBS Next Generation Application Prototype</description>
<properties>
<java-version>1.8</java-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.springframework.boot-version>1.1.7.RELEASE</org.springframework.boot-version>
</properties>
<modules>
<!-- <module>backend</module> -->
<!-- <module>business</module> -->
<module>import</module>
<!-- <module>infra</module> -->
<!-- <module>log</module> -->
<!-- <module>rest</module> -->
</modules>
<dependencyManagement>
<dependencies>
<!-- SPRING-BOOT ... -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<type>pom</type>
<version>${org.springframework.boot-version}</version>
<scope>import</scope>
</dependency>
<!-- JAVAX ... -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<!-- COMMONS ... -->
...
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5</version>
<configuration>
<tagBase>
svn://svn.int.company.at/stmlf-repository/prototype/bbsng/tags
</tagBase>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>external</id>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>**/*custom*</exclude>
<exclude>**/custom/*</exclude>
</excludes>
</resource>
</resources>
</build>
</profile>
</profiles>
</project>
If you need further information please ask. Hope you can help me.
Thank you very much.
The spring-boot-loader modules lets Spring Boot support executable jar and war files. If you use the Maven plugin or the Gradle plugin, executable jars are automatically generated, and you generally do not need to know the details of how they work.
Finally I found solution. The magic keyword is repackage, see link http://docs.spring.io/spring-boot/docs/1.1.7.RELEASE/maven-plugin/usage.html
So I only need spring-boot-maven-plugin in my web module configured with repackage goal:
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
Then all dependencies are packed in executeable jar file and is startable from console.
I hope it helps for people who face same issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With