暂时未完成....




创建完以后的目录如下:

然后配置pom.xml

再放入配置项
-
-
-
-
nexus-aliyun -
Nexus aliyun -
http://maven.aliyun.com/nexus/content/groups/public -
-
-
-
-
-
org.springframework.boot -
spring-boot-starter-parent -
1.4.0.RELEASE -
-
-
-
-
-
org.springframework.boot -
spring-boot-devtools -
true -
-
-
-
org.springframework.boot -
spring-boot-starter-thymeleaf -
-
-
-
-
-
-
-
maven-compiler-plugin -
2.3.2 -
-
1.8 -
1.8 -
UTF-8 -
-
-
-
org.springframework.boot -
spring-boot-maven-plugin -
-
再右键-->Mavent-->Update更新

选中当前项目


里面加上——spring.devtools.restart.enabled=true
server.port=8081(改启动端口号为8081)
- 依赖包
-
-
-
-
org.springframework.boot -
spring-boot-devtools -
true -
-
-
-
-
-
-
maven-compiler-plugin -
2.3.2 -
-
1.8 -
1.8 -
UTF-8 -
-
-
-
org.springframework.boot -
spring-boot-maven-plugin -
-
- 配置上去 即可
1.新建文件 ApplicationBootController

2.加入如下配置
- package boot;
-
- import org.springframework.boot.SpringApplication;
- import org.springframework.boot.autoconfigure.SpringBootApplication;
- import org.springframework.context.annotation.ComponentScan;
-
- //声明为启动类
- @SpringBootApplication
- /**
- * 管理包下所有的Component注解,包含Component的子注解,比如Service,Controller等
- */
- @ComponentScan(basePackages = { "com.tledu.kx" })
- public class ApplicationBootController {
- public static void main(String[] args) {
- SpringApplication.run(ApplicationBootController.class, args);
- }
- }
注意:@ComponentScan(basePackages = { "里面为要管理的文件夹的名字" })
3.在要控制的文件类上面都要加上 @Controller 这样才能被启动类监听到
- package com.tledu.kx;
-
- import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.CrossOrigin;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.ResponseBody;
-
- @Controller
- @EnableAutoConfiguration
- public class kx_1 {
- // 请求的地址
- @RequestMapping(value = "/userDemo1", method = RequestMethod.GET)
- @ResponseBody
- // 解决跨域
- @CrossOrigin
- public void add(){
- System.out.println("--------------11111---------");
- }
- }