intellij+springboot+springloaded 实现热部署

依赖:

dependencys目录下增加:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

project 节点下添加:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <dependencies>
                <!-- spring热部署-->
                <dependency>
                    <groupId>org.springframework</groupId>
                    <artifactId>springloaded</artifactId>
                    <version>1.2.1.RELEASE</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

java图 :

Application.java

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;

/**
 * Created by Administrator on 2015/2/10.
 */

@Configuration
@EnableAutoConfiguration
@ComponentScan
public class Application {
    public  static  void  main(String [] m){
        ApplicationContext ctx = SpringApplication.run(Application.class, m);

        System.out.println("Let's inspect the beans provided by Spring Boot:");

        String[] beanNames = ctx.getBeanDefinitionNames();
        Arrays.sort(beanNames);
        for (String beanName : beanNames) {
      //      System.out.println(beanName);
        }
    }
}

controller.java

package hello;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by  on 2015/2/15.
 */
@RestController
public class MyController {
<span style="color:#bbb529;">@RequestMapping</span>(<span style="color:#6a8759;">"/thing"</span>)
<span style="color:#cc7832;">public </span>MyThing <span style="color:#ffc66d;">thing</span>() {
    MyThing m =  <span style="color:#cc7832;">new </span>MyThing() <span style="color:#cc7832;">;

m.setId(“5”);
m.setName(“姓名”);
return m ;
}

<span style="color:#bbb529;">@RequestMapping</span>(<span style="color:#6a8759;">"/thing2"</span>)
<span style="color:#cc7832;">public </span>MyThing <span style="color:#ffc66d;">thing2</span>() {
    MyThing m =  <span style="color:#cc7832;">new </span>MyThing() <span style="color:#cc7832;">;

m.setId(“5”);
m.setName(“姓名”);
return m ;
}

mything.java

package hello;

/**
 * Created by hongpf on 2015/2/15.
 */
public class MyThing {
    public String getId() {
        return id;
    }
<span style="color:#cc7832;">public void </span><span style="color:#ffc66d;">setId</span>(String id) {
    <span style="color:#cc7832;">this</span>.<span style="color:#9876aa;">id </span>= id<span style="color:#cc7832;">;

}

<span style="color:#629755;">/**

*
*/
String id ;

public String getName() {
return name;
}

<span style="color:#cc7832;">public void </span><span style="color:#ffc66d;">setName</span>(String name) {
    <span style="color:#cc7832;">this</span>.<span style="color:#9876aa;">name </span>= name<span style="color:#cc7832;">;

}

String <span style="color:#9876aa;">name </span><span style="color:#cc7832;">;

}

当系统通过 mvn spring-boot:run启动或者 右键application debug 启动java文件时,系统会监视classes文件,当有classes文件被改动时,系统会重新加载类文件,不用重启启动服务

ps:需要重新编译文件 ctl+shift+f9

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值