关键词:
1、新建springboot项目
2、导入依赖pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.5.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.lxy</groupId> <artifactId>springboot-01-hellospringboot</artifactId> <version>0.0.1-SNAPSHOT</version> <name>springboot-01-hellospringboot</name> <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> </dependencies> <!-- 这个插件,可以将应用打包成一个可执行的jar包 --> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
pom.xml文件说明
1)、父项目
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.5.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent>
它的父项目是
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>2.2.5.RELEASE</version> <relativePath>../../spring-boot-dependencies</relativePath> </parent>
这个是真正来管理Spring Boot应用里面的所有依赖版本,SpringBoot的版本仲裁中心;
以后我们导入依赖默认不需要写版本;(没有在dependcies里面管理的依赖自然需要声明版本号)
2)、导入依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>
spring-boot-starter:spring-boot场景启动器;帮我们导入了web模块正常运行所依赖的组件
Spring Boot将所有功能的场景都抽取出来,做成一个个starters(启动器),只需要在项目里面引入这些starter相关场景的所有依赖都会导入进来
要用什么功能,就导入什么场景的启动器
3、写出程序类,主入口类
// @SpringBootApplication 标注这个类是一个springboot的应用 @SpringBootApplication public class Springboot01HellospringbootApplication { public static void main(String[] args) { // 将springboot应用启动 SpringApplication.run(Springboot01HellospringbootApplication.class, args); } }
@SpringBootApplication:Spring Boot应用标注在某个类上说明这个类是SpringBoot的主配置类,SpringBoot就应该运行这个类的main方法来启动SpringBoot应用;
@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited @SpringBootConfiguration @EnableAutoConfiguration @ComponentScan(excludeFilters = { @Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class), @Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) }) public @interface SpringBootApplication {
@SpringBootConfiguration:springboot的配置类;标注在某个类上,表示这是一个Spring Boot的配置类
@Configuration:配置类上标注这个注解;配置类 ---- 配置文件
@Component 配置类也是容器的一个组件
@EnableAutoConfiguration
springboot之helloworld
本文使用IDEA开发。createnewprojectmaven信息依赖lombokweb项目目录Controller@RestControllerpublicclassHelloWorldController{@GetMapping("hello-world")publicStringhelloWorld(){return"helloworld";}}ur 查看详情
springboot之helloworld详解
SpringBoot介绍~<暂时假装有>配置<?xmlversion="1.0"encoding="UTF-8"?><projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http: 查看详情
springboot学习随笔:简单的helloworld
接上章搭建好springboot环境后,开始开发入门级HelloWorld一.构建简单的springboot项目1.新建项目,选择Spring/SpringStarterProject2.Next此处目前阶段只选择web即可 3.Finish,生成项目(下图为参考图,非本次新建的HelloWorld项目图,除了项... 查看详情
springboot初探helloworld
...://spring.io/tools/sts/all/二、搭建helloworld项目 1.选择创建springboot向导 路径:file->new->springstartproject &nbs 查看详情
springboot入门===helloworld
昨天无意间看到SpringBoot,今天又了解了一下,试着写一个HelloWorld! 今天看了半天,最后还是要用Maven最方便!以下: 一、工具 JDK1.7 Eclipse M 查看详情
springboot2.x入门——helloworld
Springboot2.x入门——helloWorld一、简介1.1Springboot简介SpringBoot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程。该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化... 查看详情
idea创建springboot的helloworld项目
项目环境:idea2019.3jdk1.8springboot2.2.4 查看详情
3.springboot-helloworld
1、创建Controller@RestControllerpublicclassHelloController{ @RequestMapping("/hello") publicStringhello(){ return"helloworld";&n 查看详情
入门springboot-helloworld
关于SpringBoot简化Spring应用开发的一个框架;整个Spring技术栈的一个大整合-------------------------------------------开始新建第一个项目: CreateNewProject-----Maven--新建一个项目 Pom.xml中加入springboot启动的依赖 新建一个启动类,... 查看详情
springboot入门一helloworld!
微服务框架springboot,目的是用来简化新Spring应用的初始搭建以及开发过程。简化的代价,就是约定俗成很多规则,比如默认读取的配置文件名是application.properties必需在config目录下,启动类的扫描是平级及子目录。springboot并非是现... 查看详情
[springboot2]helloworld
导入依赖<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.3.4.RELEASE</version></parent><d 查看详情
springboot参考教程springboot概述及helloworld
...及与第三方框架的集成应用。使开发人员可以快速的了解SpringBoot,熟练的使用SpringBoot应用到 开发中。 笔者将全面的介绍Spr 查看详情
springboot入门
Springboot入门当然要用它写一个helloworld,这也是我们广大程序员的传统艺能.首先打开ideaultimate,不要用idea的社区版,社区办没办法使用springboot的插件,需要安装SpringAssistant才行,或者使用maven去建springboot工程.回到正题,使用idea ultim... 查看详情
springboot-helloworld实现
springboot快速入门首先,建立一个空的项目第二步:建立一个springboot项目 第三步:添加依赖:<?xmlversion="1.0"encoding="UTF-8"?><projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSch 查看详情
从零开始的springboot(1搭建一个springboot项目helloworld)
搭建一个SpringBoot项目HelloWorld1)从官网搭建项目:1、官网地址:https://spring.io/projects/spring-boot2、点击此处进入https://start.spring.io/:配置页面 3、配置如下:并点击generate 4、将生成的压缩文件保存在本地文件夹中... 查看详情
第一个springboot程序——helloworld!(代码片段)
今天写了第一个SpringBoot程序,真的感慨到SpringBoot的强大和便捷(可能是由于之前学了SpringMVC),真的超级方便下面就是我的第一个SpringBoot程序(1)创建一个maven工程(2)导入SpringBoot相关的依赖 在pom.xml中添加如下代码<?x... 查看详情
springboot-helloworld
1.1、打开官网spring.io 1.2、点击project 1.3、点击learn 1.4、点击BuildingaRESTfulWebService 1.5、下载实例源码 1.6、导入代码 1.7、启动springboot启动方式一:鼠标右键,选择debugapplication 启动方式 查看详情
springboot-helloworld
1、eclipse安装springboot插件2、new->SpringStart->group:组名称;artifact:组件名称;->选中web->finish3、复制pom文件<?xmlversion="1.0"encoding="UTF-8"?><projectxmlns="http://maven.apache.org/POM/4.0.0"xml 查看详情