springboot基础配置
时间: 2023-10-14 18:12:19 浏览: 40
Spring Boot 是一个快速开发框架,它的优点之一就是可以快速进行基础配置。下面是 Spring Boot 基础配置的步骤:
1. 添加 Spring Boot 的依赖
在 pom.xml 中添加 Spring Boot 的依赖:
```
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
```
2. 创建 Spring Boot 应用程序
创建一个 Spring Boot 应用程序,并添加注解 @SpringBootApplication:
```
@SpringBootApplication
public class MyApp {
public static void main(String[] args) {
SpringApplication.run(MyApp.class, args);
}
}
```
3. 配置 Spring Boot 应用程序
在 application.properties 文件中配置 Spring Boot 应用程序:
```
server.port=8080
spring.datasource.url=jdbc:mysql://localhost/mydb
spring.datasource.username=root
spring.datasource.password=
```
4. 运行 Spring Boot 应用程序
使用 Maven 或 Gradle 构建并运行 Spring Boot 应用程序:
```
mvn spring-boot:run
```
或者
```
gradle bootRun
```
以上就是 Spring Boot 基础配置的步骤。