弹簧启动 MVC 多模块可执行 jar
2022-09-03 05:28:36
我有一个多模块项目,用Spring boot 1.1.7构建
结构是
+ parent
+ import
+ web
+ backend
我的父模块将包括某种微服务,我想从我的父级管理的内容(所有使用的依赖项)等等。在导入/后端有我的批处理业务逻辑,在Web中有一个mvc应用程序,我可以从那里启动批处理作业。
在Eclipse中,一切对我来说都很好,我可以从应用程序启动应用程序.java文件和应用程序工作。
现在我想通过执行可执行的jar文件来执行该应用程序,但是当尝试从控制台启动时,我收到以下错误消息。
java -jar application.jar
Kein Hauptmanifestattribut in application.jar
jar非常小,只有5kb,我没有在jar包中找到任何3方依赖项的jar。
Web模块的Pom如下所示:
<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是:
<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>
而Pom of Parent是:
<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>
如果您需要更多信息,请询问。希望你能帮助我。
谢谢。