一《spring 全家桶》学习 之《第一个spring程序》

2019-02-25  本文已影响0人  讲道理很没道理

学习课程来源:https://time.geekbang.org/course/detail/156-80189
步骤1:

打开 https://start.spring.io/

image

步骤二:填写group ,以及选择依赖

步骤三:idea 打开 项目

步骤四:编写SpringBootApplication 入口文件


package com.lv.spring.hello.springdemo;

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;

@SpringBootApplication

@RestController

public class SpringDemoApplication {

public static void main(String[] args) {

SpringApplication.run(SpringDemoApplication.class, args);

  }

@RequestMapping("hello")

public Stringhello(){

return "hello Spring";

  }

}

访问 url curl http://localhost:8080/hello

其它监控功能:curl http://localhost:8080/actuator/helath

查看所有bean : http://localhost:8080/actuator/beans

image

maven 打包方式

打包 跳过测试

mvn clean package -Dmaven.test.skip

执行

cd target

dir 显示所有包咯 / ls

image

java -jar spring-demo-0.0.1-SNAPSHOT.jar

上一篇 下一篇

猜你喜欢

热点阅读