1. Maven创建SpringBoot项目
2. application.properties
spring.session.store-type=none // 解决默认的30+编译错误
3. demoNative.iml (屏蔽Mongo依赖)
<!--
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-mongodb:1.5.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver:3.4.2" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:bson:3.4.2" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver-core:3.4.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-mongodb:1.10.6.RELEASE" level="project" />
-->
4. pom.xml (屏蔽Mongo依赖)
<!--
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
-->
5. DemoApplication.java
@SpringBootApplication(exclude = {MongoAutoConfiguration.class, SecurityAutoConfiguration.class}) // 屏蔽默认Mongo设置(解决Socket链接错误) 屏蔽Tomcat用户认证(解决提示输入用户名密码)
@RestController // 使之能够路由适配
public class DemoApplication { @RequestMapping("/") // 默认路由为"Hello World!"
public String hello(){
return "Hello World!";
} public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
http://localhost:8080 默认显示 Hello World!