1. Maven建立SpringBoot項目html
2. application.propertiesjava
spring.session.store-type=none // 解決默認的30+編譯錯誤
3. demoNative.iml (屏蔽Mongo依賴)spring
<!--
<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依賴)mongodb
<!--
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
-->
5. DemoApplication.javasession
@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!app