标准如下:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>com.baeldung.spring-boot-modules</groupId>
<artifactId>spring-boot-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>spring-boot-basic-customization</artifactId>
<packaging>jar</packaging>
<name>spring-boot-basic-customization</name>
<description>Module For Spring Boot Basic Customization</description>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<!-- The main class to start by executing "java -jar" -->
<start-class>com.baeldung.changeport.CustomApplication</start-class>
</properties>
</project>
找不到主类就是因为你没有设置开始的主类是哪个,这个父类文件中在最后有一行<start-class>com.baeldung.changeport.CustomApplication</start-class>
设置了主类位置。
这里的 com.baeldung.changeport.CustomApplication,改成你主类所在位置。
MANIFEST.MF就照这个写:
Manifest-Version: 1.0
Main-Class: com.example.server.ServerApplication
Class-Path: org.springframework.boot.loader.JarLauncher
同理,com.example.server.ServerApplication改成你主类地址。
注意:这个父类设置要在pom.xml文件中<parent>
`标签中有spring-boot-starter-parent属性才会生效。 换句话就是自己手动建立的springboot中可能无法生效。
那么自己手动建立的无法生效怎么办?
看下面:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.baeldung.DemoApplication</mainClass>
</configuration>
</plugin>
</plugins>
</build>
是的,把这段代码贴进父类pom.xml文件中就完事。