This article mainly introduces a summary of the problems encountered in building a SpringBoot web-mvc project on IDEA. Friends in need can refer to it
I have been studying how to build a web-mvc project on IDEA these days. mvc's SpringBoot project, I followed online tutorials to build it step by step, but there were still a lot of problems.
In order to save everyone from taking some detours in the future, I am here to share the results of my research over the past few days, and I hope it can be helpful to everyone.
Here we first introduce the configuration information of various environments: idea2016.2.1 jdk1.8.0_31
Because SpringBoot has built-in tomcat, there is no need for additional tomcat configuration. Now Let’s start talking about how to build the SpringBoot web-mvc project on idea
Step 1:Create a new regular maven project in IDEA. Please see the following diagram for the specific steps:
Step 2:
1. First copy the following code to pox.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.example</groupId> <artifactId>demo</artifactId> <version>0.0.1-SNAPSHOT</version> <packagingexample>jar</packagingexample> <name>demo</name> <description>Demo project for Spring Boot</description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.4.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-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
body { padding: 0px; margin: auto; font-family: "黑体", "仿宋", Arial, "Arial Unicode MS", System; background-color: #00F; font-size: 20px; text-align: left; }
<html> <head> <title>Title</title> </head> <link href="css/csstest.css" rel="external nofollow" rel="stylesheet"/> <body> <p>welcome page is login.........</p> </body> </html>
#修改tomcat的默认的端口号,将8080改为8888 server.port=8888
package example; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } }
package example; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import java.util.HashMap; import java.util.Map; @Controller public class HelloController { @RequestMapping("/index") public String index(){ return "welcome"; } }
The above is the detailed content of Share some frequently asked questions about web-mvc projects building SpringBoot on IDEA. For more information, please follow other related articles on the PHP Chinese website!