一.配置和启动第一个简单的Springboot应用

(1)使用idea创建springboot项目

SpringBoot教程(一)一个简单的springboot应用启动和配置_spring配置

SpringBoot教程(一)一个简单的springboot应用启动和配置_springboot_02

SpringBoot教程(一)一个简单的springboot应用启动和配置_springboot教程_03

(2)工程结构

SpringBoot教程(一)一个简单的springboot应用启动和配置_spring_04

(3)配置文件pom

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>com.lpinfo.shop</groupId>
	<artifactId>lpinfo-shop</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>

	<name>lpinfo-shop</name>
	<description>Demo project for Spring Boot</description>

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.1.1.RELEASE</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<java.version>1.8</java.version>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>


</project>

(4)启动和运行

package com.lpinfo.shop.lpinfoshop;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class LpinfoShopApplication {

	public static void main(String[] args) {
		SpringApplication.run(LpinfoShopApplication.class, args);
	}
}

(5)运行结果

SpringBoot教程(一)一个简单的springboot应用启动和配置_springboot_05

 

(6)项目地址

https://pan.baidu.com/s/1X9yqOETnENUdDdgQBWNvCw