1、新建一个主的maven项目()使用IDEA创建SpringBoot项目 (谢谢这位小哥)
2、在建好的项目上右键--》new ---> module 选择maven---> next ,artifactId 中输入 Web
完成,点击finish
同样的道理,在此创建model模型层和persistence
这里说下相互依赖管理:
web ---->persistence----->>>model
所以相关xml配置
web.xml
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>jerryspringboot.JerrySpringBootFirstApplication</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
persistence.xml配置 ,引入model
model的pom.xml
总项目的pom.xml
<?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>
<groupId>com.jerry</groupId>
<artifactId>jerry-spring-boot-first</artifactId>
<version>0.0.1-SNAPSHOT</version>
<modules>
<module>web</module>
<module>persistence</module>
<module>model</module>
</modules>
<!-- 修改成pom -->
<!--
模型层:model
持久层:persistence
表示层:web
web 依赖persistence
-->
<packaging>pom</packaging>
<name>jerry-spring-boot-first</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
最后项目打包:
切换到web项目的target下面, 使用命令
mvn -Dmaven.test.skip -U clean package
然后运行jar包:
java -jar web-xxxxx.jar