springboot学习笔记1——springboot初始化

       写在开头:虽然工作了,但都是业务逻辑,了解业务的基础上码砖头就好了,但是框架配置,设计、架构等方面还是得靠自己去充电。本来准备买慕课上的实战网课进行学习,后来还是感觉先把基础打牢再开始实战印象才是最深的。本次学习笔记都来自方志鹏老师的博客    https://www.fangzhipeng.com/springboot/2017/05/01/springboot1.html

一、简介

       springboot 的设计目的就是简化开发,开启了各种自动装配,你不想写各种配置文件,引入相关的依赖就能迅速搭建起一个web工程。它采用的是建立生产就绪的应用程序观点,优先于配置的惯例。配置变简单、编码变简单,部署变简单,就好比用了IDEA,再也回不到Eclipse一样。

二、项目初始化

       打开Idea-> new Project ->Spring Initializr ->填写group、artifact ->钩上web(开启web功能)->点下一步就行了。如果你是社区版则需要下载spring assistant。

自动创建完的项目结构:

pom依赖:我还点了几个插件的选项,如不用写getter,setter方法的lombok工具等,这些配置都是默认帮你搞定的,让你专注于你的自己的业务开发,而不是各种配置。其中spring-boot-starter-web不仅包含spring-boot-starter,还自动开启了web功能。

<?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.2.RELEASE</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.dennis</groupId>
	<artifactId>demo</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>demo</name>
	<description>Dennis first 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-devtools</artifactId>
			<scope>runtime</scope>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-configuration-processor</artifactId>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<optional>true</optional>
		</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>

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

</project>

三、项目启动

和ssm框架不同的地方是:

  • 你没有做任何的web.xml配置。
  • 你没有做任何的sping mvc的配置; springboot自动配置。
  • 你没有配置tomcat ;springboot内嵌tomcat.

如果加入看日志的代码,在程序启动的时候,会看到控制台打出springboot自动诸如注入了40-50个bean.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值