SpringBoot2学习1 环境搭建

导包

 <!-- Inherit defaults from Spring Boot -->
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.1.6.RELEASE</version>
	</parent>
	<!-- Add typical dependencies for a web application -->
	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
	</dependencies>

启动类

package com.zz;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
 * 右键--》run as application  运行正启动类的main方法,就可以启动这个springboot项目。
SpringBoot 自带了 tomcat, 运行这个main方法 的时候,会同时启动tomcat
 * @author jiyu
 *
 */
@SpringBootApplication
public class App {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		SpringApplication.run(App.class, args);
	}

}


右键–》run as application 运行正启动类的main方法,就可以启动这个springboot项目。
SpringBoot 自带了 tomcat, 运行这个main方法 的时候,会同时启动tomcat

启动成功的日志

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.6.RELEASE)

2019-08-03 21:27:18.453  INFO 16564 --- [           main] com.zz.App                               : Starting App on DESKTOP-9FM4ENL with PID 16564 (C:\bsea\wp\2019\07\02\SpringBoot2\SpringBootBasic\target\classes started by jiyu in C:\bsea\wp\2019\07\02\SpringBoot2\SpringBootBasic)
2019-08-03 21:27:18.460  INFO 16564 --- [           main] com.zz.App                               : No active profile set, falling back to default profiles: default
2019-08-03 21:27:21.273  INFO 16564 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2019-08-03 21:27:21.342  INFO 16564 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-08-03 21:27:21.343  INFO 16564 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.21]
2019-08-03 21:27:21.496  INFO 16564 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-08-03 21:27:21.496  INFO 16564 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2926 ms
2019-08-03 21:27:21.736  INFO 16564 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-08-03 21:27:21.947  INFO 16564 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2019-08-03 21:27:21.950  INFO 16564 --- [           main] com.zz.App 

测试controller

package com.zz.controller;

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

@RestController
public class TestController {
	
	@RequestMapping("hello")	
	public String t1(){
		return "hello SpringBoot";
	}
}

测试

在这里插入图片描述

添加 热启动功能

STS 或者Eclipse 只需要在pom文件加入一个包,就可以实现热启动

<!--目的:《可选》引入springboot 热启动,每次修改以后,会自动把改动加载,不需要重启服务了-->
        <dependency> <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值