/imooc-springboot-starter/src/main/resources/application.properties

#关闭缓存,  即时刷新
#spring.freemarker.cache=false
spring.thymeleaf.cache=true #热部署生效
spring.devtools.restart.enabled=true
#设置重启的目录,添加那个目录的文件需要restart
spring.devtools.restart.additional-paths=src/main/java
# 为mybatis设置, 生产环境可删除
#restart.include.mapper=/mapper-[\\w-\\.]+jar
#restart.include.pagehelper=/pagehelper-[\\w-\\.]+jar
#排除那个目录的文件不需要restart
spring.devtools.restart.exclude=static/**,public/**,WEB-INF/**
#classpath目录下的WEB-INF文件夹内容修改不重启
#spring.devtools.restart.exclude=WEB-INF/**

/imooc-springboot-starter/pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>com.imooc</groupId>
<artifactId>imooc-springboot-starter</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <name>imooc-springboot-starter</name>
<description>Demo project for Spring Boot</description> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- 热部署 -->
<!-- devtools可以实现页面热部署(即页面修改后会立即生效,
这个可以直接在application.properties文件中配置spring.thymeleaf.cache=false来实现) -->
<!-- 实现类文件热部署(类文件修改后不会立即生效),实现对属性文件的热部署。 -->
<!-- 即devtools会监听classpath下的文件变动,并且会立即重启应用(发生在保存时机),
注意:因为其采用的虚拟机机制,该项重启是很快的 -->
<!-- (1)base classloader (Base类加载器):加载不改变的Class,例如:第三方提供的jar包。 -->
<!-- (2)restart classloader(Restart类加载器):加载正在开发的Class。 -->
<!-- 为什么重启很快,因为重启的时候只是加载了在开发的Class,没有重新加载第三方的jar包。 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<!-- optional=true, 依赖不会传递, 该项目依赖devtools;
之后依赖boot项目的项目如果想要使用devtools, 需要重新引入 -->
</dependency>
</dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build> </project>

/imooc-springboot-starter/src/main/java/com/imooc/controller/UserController.java

package com.imooc.controller;

import java.util.Date;

//import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import com.imooc.pojo.LeeJSONResult;
import com.imooc.pojo.User; //@Controller
@RestController // @RestControler = @Controller + @ResponseBody
@RequestMapping("/user")
public class UserController { //@RequestMapping("/hello")
@RequestMapping("/getUser")
//@ResponseBody
public User hello() {
//public User getUser() {
User u = new User();
u.setName("imooc");
u.setAge(18);
u.setBirthday(new Date());
u.setPassword("imooc");
//u.setDesc(null);
u.setDesc("hello imooc~~"); return u; }
@RequestMapping("/getUserJson")
//@ResponseBody
public LeeJSONResult hello1() {
//public LeeJsonResult getUserJson() {
User u = new User();
//u.setName("imooc");
u.setName("imooc1");
u.setAge(18);
u.setBirthday(new Date());
u.setPassword("imooc");
//u.setDesc(null);
//u.setDesc("hello imooc~~");
u.setDesc("hello imooc1~~"); return LeeJSONResult.ok(u); }
}

/imooc-springboot-starter/src/main/java/com/imooc/controller/UserController.java

package com.imooc.controller;

import java.util.Date;

//import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import com.imooc.pojo.LeeJSONResult;
import com.imooc.pojo.User; //@Controller
@RestController // @RestControler = @Controller + @ResponseBody
@RequestMapping("/user")
public class UserController { //@RequestMapping("/hello")
@RequestMapping("/getUser")
//@ResponseBody
public User hello() {
//public User getUser() {
User u = new User();
//u.setName("imooc");
u.setName("imooc1");
u.setAge(18);
u.setBirthday(new Date());
//u.setPassword("imooc");
u.setPassword("imooc1");
//u.setDesc(null);
//u.setDesc("hello imooc~~");
u.setDesc("hello imooc1~~"); return u; }
@RequestMapping("/getUserJson")
//@ResponseBody
public LeeJSONResult hello1() {
//public LeeJsonResult getUserJson() {
User u = new User();
//u.setName("imooc");
u.setName("imooc1");
u.setAge(18);
u.setBirthday(new Date());
u.setPassword("imooc");
//u.setDesc(null);
//u.setDesc("hello imooc~~");
u.setDesc("hello imooc1~~"); return LeeJSONResult.ok(u); }
}

最新文章

  1. JavaScript 字符串处理详解
  2. Android项目中,在一个数据库里建立多张表
  3. Bluetooth RFCOMM介绍
  4. (转)用Eclipse进行C++开发时Bianry not found的问题解决
  5. NFA和DFA区别
  6. weblogic11g 安装——linux 无图形界面
  7. [Eclipse]The type XXX cannot be resolved. It is indirectly referenced from required .class files
  8. QDialog 添加最大化、最小化按钮和关闭按钮,并且要正常显示
  9. iOS:Block写递归
  10. python元类分析
  11. PHP文件夹操作
  12. swiper使用小结
  13. vue 2.0 scopedSlots和slots在render函数中的应用示例
  14. C# Web开发中弹出对话框的函数[转载]
  15. rabbitmq - java client lib一二事
  16. week06 codelab01 react-router 去官网学习
  17. android:应用性能优化SparseArray
  18. linux中echo命令详解
  19. 【算法学习】【洛谷】cdq分治 &amp; P3810 三维偏序
  20. 二维码扫描开源库ZXing定制化

热门文章

  1. OS X 10.11 El Capitan 三指拖动的开启方法
  2. Java中常见的比较器的实现方法
  3. MySql简单分页存储过程
  4. 常用T-CODE ,快捷键
  5. 【WCF】利用WCF实现上传下载文件服务
  6. 搭建Rsync服务器
  7. hdoj-1013-Digital Roots(九余数定理)
  8. python list的extend和append方法
  9. C++中头文件、源文件之间的区别与联系
  10. Spring框架实现——远程方法调用RMI代码演示