SpringBoot在无网络的环境下运行

首先创建一个maven项目,和创建一个Spring项目一样

在pom文件中引入相关的依赖,依赖是以前引过的




         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

   
    
        org.springframework.boot
        spring-boot-starter-parent
        2.0.3.RELEASE
         
    
    4.0.0

    springboot-02
    war

    springboot-02 Maven Webapp
    
    http://www.example.com

    
    
        UTF-8
        UTF-8
        1.8
    

    
        
            junit
            junit
            4.11
            test
        

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

        
            org.springframework.boot
            spring-boot-starter-test
            test
        
    

    
        springboot-02
    

编写的Controller和SpringBoot一样

package cn.studio.controller;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * Created by mycom on 2018/6/22.
 */
@SpringBootApplication
@RestController
public class HelloController {

    @RequestMapping("/hello")
    public Object hello(){
        return "你好我好";
    }

    public static void main(String[] args) {
        
        SpringApplication.run(HelloController.class, args);
    }
}

 

转载于:https://www.cnblogs.com/my-123/p/9214563.html

你可能感兴趣的:(SpringBoot在无网络的环境下运行)