gpt4 book ai didi

java - spring boot主类,如何指定

转载 作者:行者123 更新时间:2023-12-02 11:57:36 30 4
gpt4 key购买 nike

我正在使用 spring-boot 开发一个项目。我有自己的父 .pom 文件,所以我无法使用 spring-boot 父 pom。当我打包项目时,主类没有包含在 MANIFEST.MF 中,即使我在插件配置中指定了它。因此,当我尝试运行该 jar 时,java 说它找不到主类。

no main manifest attribute, in processor-interface-1.0.0.jar

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>tld.domain.system</groupId>
<artifactId>processor-interface</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>

<parent>
<groupId>tld.domain.maven</groupId>
<artifactId>super-pom</artifactId>
<version>[0.1,1.0)</version>
</parent>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<log4j.version>2.9.1</log4j.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.5.6.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.6.RELEASE</version>
<configuration>
<mainClass>tld.domain.system.boot.ProcessorInterface</mainClass>
</configuration>
</plugin>
</plugins>
</build>

我深入研究了 .jar 文件中的 MANIFEST.MF,确实没有 main-class: 行。如何在 pom 中指定主类,以便将其包含在 MANIFEST.MF 中?

最佳答案

我有类似的设置,唯一的区别是我的 spring-boot-maven-plugin 执行与 repackage 阶段相关:

            <plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>my main class</mainClass>
</configuration>
</plugin>

关于java - spring boot主类,如何指定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47477861/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com