赞
踩
通过idea工具创建工程时,不再选择maven了而是选择spring initializr。然后去勾选相关依赖。
注意:
1、项目坐标的名字
不一定非要和包的名字
一致(默认创建的时候,idea给我们设置是一致的,但是我们可以改):
注意:
1、引入spring web依赖的目的:可以看一下右侧对spring web的介绍。如果不引人这个依赖,你的项目是启动不成功的。
点击Finish之后,生成的文件、目录如下。
<parent>
是spring-boot-starter-parent
;spring-boot-starter-web
、pring-boot-starter-test
;<?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.6.7</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>spring-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-demo</name>
<description>spring-demo</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-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>
test
;@SpringBootApplication
public class SpringSecurityDemo001 {
public static void main(String[] args) {
SpringApplication.run(SpringSecurityDemo001.class, args);
}
}
SpringBootTest
;https://blog.csdn.net/qq_43783527/article/details/124553412
1、读取application.properties
文件中的值的方式:
https://blog.csdn.net/weixin_42344117/article/details/118087641
2、读取非application.properties
文件中的值的方式:
https://blog.csdn.net/weixin_42344117/article/details/117605507
email.message.pull.all.executor.corePoolSize = 10
email.message.pull.all.executor.maximumPoolSize = 50
email.message.pull.all.executor.keepAliveTime = 5
email.message.pull.all.executor.workQueueCapacity = 500
lombok更多使用方式:
https://blog.csdn.net/itCatface/article/details/119038565
引入lombok依赖:
<!--集成lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
使用@Setter、@Getter注解的包是lombok
,不是jdk.nashorn.internal.objects.annotations
下的注解;
package com.example.springdemo.config.executor;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Setter
@Getter
@Component
@ConfigurationProperties(prefix = "email.message.pull.all.executor")
public class MessagePullAllExecutorConfig {
private Integer corePoolSize;
private Integer maximumPoolSize;
private long keepAliveTime;
private Integer workQueueCapacity;
}
https://blog.csdn.net/Smy_0114/article/details/122229852
我们采用:@Configuration+@Bean的方式。
SpringBoot集成@Slf4j:
http://t.csdn.cn/Hc1QO
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。