IntelliJ IDEA 搭建 Spring Boot Maven 多模块项目
1.1 创建父项目
1.2 父项目创建完需手动删除 src 目录
2.1 父级项目 mutiple-project 配置 pom.xml
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.mutiple
mutiple-project
1.0-SNAPSHOT
pom
http://www.example.com
UTF-8
1.8
1.8
1.5.19.RELEASE
org.springframework.boot
spring-boot-starter-parent
1.5.19.RELEASE
io.spring.platform
platform-bom
Brussels-SR16
pom
import
org.springframework.boot
spring-boot-dependencies
${spring-boot.version}
pom
import
javax.servlet
javax.servlet-api
4.0.1
provided
net.sourceforge.nekohtml
nekohtml
1.9.22
org.thymeleaf.extras
thymeleaf-extras-springsecurity3
3.0.4.RELEASE
org.springframework.boot
spring-boot-maven-plugin
${spring-boot.version}
repackage
3.1 创建子级 Web 模块, 一般用于业务入口
3.2 删除模块内 webapp 目录
3.3 java, resources 如没有需要手动生成,之后需手动设置为 IntelliJ IDEA 认的之源目录
4. 子级模块 mutiple-web
4.1 配置 pom.xml
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
mutiple-project
com.mutiple
1.0-SNAPSHOT
4.0.0
com.mutiple
mutiple-web
jar
mutiple-web Maven Webapp
http://www.example.com
org.springframework.boot
spring-boot-starter-web
net.sourceforge.nekohtml
nekohtml
org.thymeleaf.extras
thymeleaf-extras-springsecurity3
org.springframework.boot
spring-boot-starter-thymeleaf
javax.servlet
javax.servlet-api
provided
mutiple-web
org.springframework.boot
spring-boot-maven-plugin
4.2 resources 目录内创建环境文件 application.properties
#HTML Templete
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.cache=false
spring.thymeleaf.check-template=true
spring.thymeleaf.check-template-location=true
spring.thymeleaf.prefix=classpath:public/
spring.thymeleaf.content-type=text/html
spring.thymeleaf.suffix=.html
spring.thymeleaf.encoding=UTF-8
4.3 resources 目录内创建目录 public 再生成 test.html 文件 (用于测试)
Hello World!!
4.4 创建 Controller
package com.mutiple;
import com.mutiple.service.DateUtil;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
@Controller
public class TestController {
@RequestMapping("/test")
public String test(Model model) {
return "test";
}
}
4.5 创建启动文件
package com.mutiple;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@ComponentScan(basePackages = {"com.mutiple"})
@SpringBootApplication
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
4.6 启动项目
标签:IntelliJ,Spring,boot,springframework,thymeleaf,mutiple,Boot,spring,org
来源: https://blog.csdn.net/qcl108/article/details/100703768