美文网首页
spring-boot demo搭建(maven)

spring-boot demo搭建(maven)

作者: 夏日橘子冰 | 来源:发表于2017-04-06 09:44 被阅读0次

step1:新建简单maven项目,从pom.xm开始l如下:

step2 :编写代码结构如下:

附:application.java代码

package project;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication

public class Application {

public static void main(String[] args) throws Exception {

      SpringApplication.run(Application.class, args);

      }

}

step3:启动

常用 jar包+命令启动

dependencies节点下添加maven插件依赖,maven项目默认打包为可执行的jar包。

在jar包目录下,命令   java  -jar xxxxx.jar!

以下步骤为web项目所需:

step4 :添加spring-starter-web模块依赖以及其他相关依赖如下:

step5:编写代码

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

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

@RestController

public class Hello {

@RequestMapping("/")

public String sayHello(){

return "hello spring-boot!";

}

}

相关文章

网友评论

      本文标题:spring-boot demo搭建(maven)

      本文链接:https://www.haomeiwen.com/subject/cnpfattx.html