版本
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.8</version>
<relativePath/>
</parent>
依赖
<dependencies>
<!--lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!--thymeleaf-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!--springMVC-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--springBoot起步依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!--test-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
插件
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.2.2</version>
<configuration>
<!-- 镜像名 -->
<imageName>${project.artifactId}</imageName>
<!-- 镜像版本 -->
<imageTags>
<imageTag>${project.version}</imageTag>
</imageTags>
<!-- Docker路径 -->
<dockerHost>http://ip:2375</dockerHost>
<!-- Dockerfile定义 -->
<baseImage>openjdk:11</baseImage>
<!-- 作者 -->
<maintainer>jkw</maintainer>
<resources>
<resource>
<targetPath>/</targetPath>
<!-- 从哪个包拷贝文件,target包 -->
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
<workdir>/</workdir>
<entryPoint>["java", "-jar", "${project.build.finalName}.jar"]</entryPoint>
<forceTags>true</forceTags>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
配置文件application.yml
server:
port: 8080
启动类
/**
* 启动类
*/
@SpringBootApplication//启动类的一个注解
public class Main {
public static void main(String[] args) {
SpringApplication.run(Main.class, args);
}
}