1、配置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.easytest</groupId>
<artifactId>rebushu</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <name>rebushu</name>
<url>http://maven.apache.org</url>
<description>Demo project for Spring Boot</description> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.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-web</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.15</version>
</dependency> <!--&lt;!&ndash; spring boot devtools 依赖包. &ndash;&gt;-->
<!--<dependency>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-devtools</artifactId>-->
<!--<optional>true</optional>-->
<!--<scope>true</scope>-->
<!--</dependency>-->
</dependencies> <!--构建节点-->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!--<configuration>-->
<!--&lt;!&ndash;fork : 如果没有该项配置,肯呢个devtools不会起作用,即应用不会restart &ndash;&gt;-->
<!--<fork>true</fork>-->
<!--</configuration>--> <dependencies>
<!--springloaded hot deploy -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.4.RELEASE</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions> </plugin> </plugins>
</build> </project>

2、书写测试代码pojo(实体类)

 package com.easytest;

 import com.alibaba.fastjson.annotation.JSONField;

 import java.util.Date;

 /**
* Created by liuya on 2018-01-17.
*/
public class UserPoJo
{
private int userId;
private String userName;
@JSONField(format="yyyy-MM-dd HH:mm:ss")
private Date createTime; public Date getCreateTime() {
return createTime;
} public void setCreateTime(Date createTime) {
this.createTime = createTime;
} public int getUserId() {
return userId;
} public void setUserId(int userId) {
this.userId = userId;
} public String getUserName() {
return userName;
} public void setUserName(String userName) {
this.userName = userName;
} @Override
public String toString() {
return "UserPoJo{" +
"userId=" + userId +
", userName='" + userName + '\'' +
", createTime=" + createTime +
'}';
}
}

3、书写测试服务器

 package com.easytest;

 import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import java.util.ArrayList;
import java.util.List; @SpringBootApplication
public class RebushuApplication extends WebMvcConfigurerAdapter { /**
// * 在这里我们使用 @Bean注入 fastJsonHttpMessageConvert
// * @return
// */
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { // 1、需要先定义一个 convert 转换消息的对象;
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); //2、添加fastJson 的配置信息,比如:是否要格式化返回的json数据;
FastJsonConfig fastJsonConfig = new FastJsonConfig();
fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat); //处理中文乱码
List<MediaType> fastMediaTypes = new ArrayList<>();
fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
fastConverter.setSupportedMediaTypes(fastMediaTypes); //3、在convert中添加配置信息.
fastConverter.setFastJsonConfig(fastJsonConfig); HttpMessageConverter<?> converter = fastConverter;
converters.add(fastConverter);
} public static void main(String[] args) {
SpringApplication.run(RebushuApplication.class, args);
}
}

4、书写controller代码

 package com.easytest;

 import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import java.util.Date; /**
* Created by liuya on 2018-01-16.
*
* 测试用的一个helloworld例子
*/ @RestController
public class ControllerJson { @RequestMapping("user2")
public UserPoJo hello(){
//实体类赋值
UserPoJo userPoJo = new UserPoJo();
userPoJo.setUserId(111);
userPoJo.setUserName("王小二");
userPoJo.setCreateTime(new Date());
//返回实体类
return userPoJo;
}
}

5、编译器配置(详见:http://www.cnblogs.com/liuyangfirst/p/8318664.html)

6、maven启动,在编译器右侧栏点开右侧栏

7、访问网页测试一下是否联通

8、controller中加如下内容,然后F5刷新界面,如图就是成功实现热部署

IntelliJ IDEA 2017版 springloaded实现热部署的更多相关文章

  1. IntelliJ IDEA 2017版 spring-boot-devtools实现热部署

    1.配置pom.xml文档 <?xml version="1.0" encoding="UTF-8"?> <project xmlns=&qu ...

  2. IntelliJ IDEA 2017版 加载springloaded-1.2.4.RELEASE.jar实现热部署

    1.配置pom.xml文档(详见:http://www.cnblogs.com/liuyangfirst/p/8318664.html) <?xml version="1.0" ...

  3. IntelliJ IDEA 14 利用JRebel实现热部署

    特别鸣谢:http://wlb.wlb.blog.163.com/blog/static/467413201522095132658/ ©IntelliJ IDEA开源社①群 185441009 鸣谢 ...

  4. 在oaf中集成SpringLoaded实现热部署

    首先声明:其实JRebel和Spring-Loaded就是一个开发环境下的利器,skip build and redeploy process,大大提升了工作效率!而非生产环境的利器... 不要在生产 ...

  5. Spring Boot学习总结(4)——使用Springloaded进行热部署

    我在开发的时候,总是会及时对自己的程序进行测试,总是频繁的重启web server,容器不烦我们都觉得烦了. dependencys目录下增加: <dependency> <grou ...

  6. java~通过springloaded实现热部署

    之前写过使用自定义的classLoader进行动态加载,热部署:它有很多弊端,我总结一下: 当前项目不能引用第三方包 当前项目必须使用反射的方式调用第三方包的方法 写死的一些路径 springload ...

  7. IntelliJ IDEA 14 利用JRebel实现热部署 二

    前言:今天下午和一个qq群里讨论JRebel时,忽然得到“自动部署”的奥秘--真有听君一席话,胜读十年书的感悟. 这是此群友的热部署博客:http://blog.csdn.net/martinkey/ ...

  8. IntelliJ IDEA 2017版 快捷键CTRL + SHIFT + A无效如何调试(详细的开启idea自动make功能 )

    1.前景描述 因为我把编译器的快捷键都设置成eclipse模式了,所以要做热部署的时候,需要CTRL + SHIFT + A --> 查找Registry --> 找到并勾选compile ...

  9. Spring Boot 项目在 IntelliJ IDEA 中配置 DevTools 实现热部署(macOS 系统)

    要配置的内容: 1.Preference -> Build, Execution, Deployment -> Complier -> Build project automatic ...

随机推荐

  1. Spring MVC 自定义视图

    实现View import org.springframework.stereotype.Component; import org.springframework.web.servlet.View; ...

  2. as3 arguments.callee与... (rest)

    import flash.display.Sprite; var count:int = 1; ArgumentsExample() function ArgumentsExample() { fir ...

  3. jboss 异常处理

    异常: jboss.aop:service=AspectManager 15:19:46,361 ERROR [ScannerThread] [MainDeployer] org.jboss.depl ...

  4. 前端-CSS-7-标准文档流&行内元素和块级元素转换

    1.什么是标准文档流 <!--  什么是标准文档流 宏观的将,我们的web页面和ps等设计软件有本质的区别 web 网页的制作 是个“流” 从上而下 ,像 “织毛衣” 而设计软件 ,想往哪里画东 ...

  5. vue深入了解组件——处理边界情况

    一.访问元素&组件 在绝大多数情况下,我们最好不要触达另一个组件实例内部或手动操作DOM元素.不过也确实在一些情况下做这些事情是合适的. 1.1 访问根实例 在每个 new Vue 实例的子组 ...

  6. 如何在java中发起http和https请求

    一般调用外部接口会需要用到http和https请求. 一.发起http请求 1.写http请求方法 //处理http请求 requestUrl为请求地址 requestMethod请求方式,值为&qu ...

  7. MySql的基本架构演变

    [MySql的基本架构演变] 没有并发的增长,也就没有必要做高可扩展性的架构. Scale-up :  纵向扩展,通过替换为更好的机器和资源来实现伸缩,提升服务能力 Scale-out : 横向扩展, ...

  8. ORACLE system表空间满

    解决方法:执行迁移命令,将AUD$表相关移到其它表空间中,也可以新建 一个审计 表空间 / MB DESC) ; alter table aud$ move tablespace SIEBELINDE ...

  9. Web标准:二、一列布局

    知识点: 1.一列固定宽度 2.一列固定宽度居中 3.一列自适应宽度 4.一列自适应宽度居中 5.一列二至多块布局   1)一列固定宽度 下图是定义了一个高300px,宽400px,颜色是#99FFc ...

  10. .net 发送邮件失败

    1,是否为企业邮箱,如果是则用最高admin的帐号,降低其安全级别,下面的子帐号自动适用.(Google 阻止了从某个不够安全的应用进行的登录尝试) 2,做一个测试页面,对错误结果进行分析,一步一步查 ...