spring-boot之概述及入门程序(一)

1:spring boot概述
1.1 什么是springboot
    去除xml繁琐配置。基于配置化组件完成日常开发(提高开发效率)。
1.2 springboot和核心功能
    独立运行的spirng项目
    内嵌servlet容器
    提供starter简化maven配置
    自动配置spring
    准生产的应用监控
无代码生产和xml配置
1.3 spring boot的优点
    项目快速构建
    对主流框架无配置集成
    项目独立运行,无需依赖servlet容器
    提供运行时的应用监控

    与云计算的天然集成

2.快速搭建spring boot项目

依赖工程

<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>1.4.1.RELEASE</version>
	</parent>
<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
			<!-- <version></version> 由于我们在parent指定了 parent(spring boot) -->
		</dependency>

pom配置

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>com.spring-boot2</groupId>
		<artifactId>gytlv</artifactId>
		<version>0.0.1-SNAPSHOT</version>
	</parent>
	<artifactId>gytlv-zm-springboot</artifactId>
	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
			<!-- <version></version> 由于我们在parent指定了 parent(spring boot) -->
		</dependency>
	</dependencies>
	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<configuration>
					<skipTests>true</skipTests>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<!-- <configuration>
					<mainClass>com.zm.blog.BlogStart</mainClass>
				</configuration> -->
				<!-- <executions>
					<execution>
						<goals>
							<goal>repackage</goal>
						</goals>
					</execution>
				</executions> -->
			</plugin>
		</plugins>
	</build>
</project>
入门程序编写
package com.starter;

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:spring boot项目的核心注解,主要目的是开启自动配置。
 * main方法:主要作用是作为项目的启动入口。
 * @author Hiiso
 *
 */
@RestController
@SpringBootApplication
public class AppStart {
	@RequestMapping("/")
	 String index(){
		return "hello boot";
	}
	
	
	public static void main(String[] args) {
		SpringApplication.run(AppStart.class, args);
	}
	
	
}


猜你喜欢

转载自blog.csdn.net/z3133464733/article/details/80350372