# springBoot-learn
**Repository Path**: worldcreator/springBoot-learn
## Basic Information
- **Project Name**: springBoot-learn
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 0
- **Created**: 2021-03-15
- **Last Updated**: 2021-06-30
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
###springBoot就是将许多框架整合在了一起,方便使用-配置
###IDEA 创建springBoot项目
* new project-spring initializr-选择 group & artifact & java version
####pom文件关键部分:
```xml
org.springframework.boot
spring-boot-starter-parent
2.4.3
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-thymeleaf
org.springframework.boot
spring-boot-starter-test
test
junit
junit
test
4.12
org.springframework.boot
spring-boot-maven-plugin
2.4.3
```
###为什么以parent引入springBoot
>spring-boot-starter-parent定义了父pom,里面给许多常用依赖定义的版本(利用dependencyManagement)
>在项目中引入依赖时就可以不需要定义version,直接默认使用父pom中的版本,本实例中spring-boot-starter-web就是参考父pom的版本
>如果pom文件中 dependency左侧旁边有个蓝色图标,那就是父pom中有其定义
##配置 resources/application.yml(将properties重名为yml,使用yml语法)
```yaml
server:
port: 8030 #配置tomcat端口,springBoot内置tomcat
spring:
application:
name: user
datasource: #数据源
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/mybatis?useUnicode=true&characterEncoding=UTF-8
username: root
password: 12345
mybatis:
mapper-locations: classpath:com/hll/demo/mapper/*.xml #配置映射文件
type-aliases-package: com.hll.demo.pojo #配置实体类
```
###导入 mybatis依赖
```xml
org.mybatis.spring.boot
mybatis-spring-boot-starter
2.1.4
mysql
mysql-connector-java
runtime
5.1.47
```
>编写实体类User, interface UserMapper & xml, UserService & UserServiceImpl, UserController
>最后启动DemoApplication的main方法即可, 地址栏 localhost:8080/index (由controller帮我们跳转)
>其中html等文件放在resources\templates中,而css\js文件放在 static中
####最后,注解很重要,多看看各层类的代码