Idea create a new Spring Boot project + brief introduction to the project directory + project package and run + import Module project can not identify the problem (all reported in red or gray) solution--Rookie Xiaohui

Idea create a new Spring Boot project + brief introduction to the project directory + project package and run + import Module project can’t identify the problem (all report red or gray)


  • This article mainly records the first use of idea to create a Spring Boot project and common problems, suitable for beginners. Before that, eclipse was used, and the package was generally war package, and the project was deployed using external tomcat.
    In addition, the spring boot project has built-in tomcat, which can be directly deployed as a jar package.
  • First of all, it is recommended to change your maven warehouse to download the required jar package faster: modify the dependencies of the maven warehouse in seconds

One, create a new Spring Boot jar package project

  1. enter description here
  2. enter description here
  3. enter description here

2. Create a new Spring Boot war package project

  • The new project options are different: enter description here
  • Add external tomcat pom dependency
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-tomcat</artifactId>
   <scope>provided</scope>
</dependency>
  • New web.xml
  1. enter description here
  2. Then select Modules, click web (if not, click the plus sign in the upper left corner to create a new one), then double-click the first item in the Web Resource Directory below, here is to set the path of the webapp, usually it is automatically set, directly Click ok, then click yes.
    enter description here
  3. Finally, click the plus sign above to create a new web.xml
    enter description here
  4. Pay attention to the path here, and put it in the webapp folder just created. Click ok, and then click ok, the web.xml is created.
    enter description here
  • At this point, the war package project is created, and the war package project can be run using external tomcat.

Three, a brief introduction to the project catalog

enter description here


Fourth, the project is packaged and run

  1. Maven on the right, find the project, install
    enter description here
  2. jar package operation (the host has jdk)
java -jar 包名
//Linux中后台运行
nohup java -jar 包名 &
  1. Run the war package (under tomcat's webapps folder)
    enter description here

5. Common problems for novices-After the module transfer, all items are grayed out or errors are reported.

  • Phenomenon as shown
    enter description here
  • solve
  1. Find maven on the right side of idea
    enter description here
  2. Found no such module here
    enter description here
  3. Add the pom.xml of the module
    enter description here
  • problem solved
    enter description here

Guess you like

Origin blog.csdn.net/qq_39231769/article/details/103098524
Recommended