创建maven项目,springboot启动,热部署配置(保存java项目即重新编译重启)

1.创建好的maven项目,在pom.xml中引入以下配置为配置springboot启动   

    
      org.springframework.boot
      spring-boot-starter-web

      1.5.4.RELEASE
      

2.新建的启动类StartApplication.java(@SpringBootApplication标识这是一个springboot启动入口):

package com.stock;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * @Description 程序启动类
 * @Date 2019年1月20日 下午4:39:59
 */
@SpringBootApplication
public class StartApplication {
   
    public static void main( String[] args )
    {
         SpringApplication.run(StartApplication.class, args);
    }
}

3.配置项目为热部署(修改Java文件保存后自动编译),修改pom.xml配置(父启动类中添加了版本后,子启动类不用添加版本号):

 

 
      org.springframework.boot
      spring-boot-starter-parent
      1.5.4.RELEASE
  
    
  
        
      org.springframework.boot
      spring-boot-starter-web
      
    
      junit
      junit
      3.8.1
      test
    
  
     
     
         org.springframework.boot
         spring-boot-devtools
         true
        true
     
  

4.测试类TestController.java中使用:

package com.stock.index.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
/**
 * @Description index的控制类
 * @Date 2019年1月20日 下午5:04:27
 */
@RestController
public class IndexController {

    @RequestMapping("/index")
    public String index() {
        return "hello world!";    
    }

}

6.浏览器中输入:http://localhost:8080/index访问系统

7.修改IndexController.java类保存,项目自动编译重启

你可能感兴趣的:(创建maven项目,springboot启动,热部署配置(保存java项目即重新编译重启))