IDEA SpringBoot新项目避坑指南.md

##IDEA SpringBoot新项目避坑指南.md

1. 坑1: 程序包org.junit不存在的解决方案

修改后的pom.xml文件依赖:

1
2
3
4
5
6
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<!-- 默认的版本为3.8.1,修改为4.x,因为3.x使用的为编程的方式,4.x为注解的形式。 -->
<version>4.12</version>
</dependency>

2. 坑2: Whitelabel Error Page

  • 修改正确的工程目录
    1
    2
    3
    4
    5
    └── com
    └── example
    ├── DemoApplication.java
    └── controller
    └── IndexController.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package com.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
//@ComponentScan(basePackages = {"com.example.controller"})
public class DemoApplication {

public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}

}
坚持原创技术分享,您的支持将鼓励我继续创作!