# ljj-springboot-study
**Repository Path**: xxljunjun/ljj-springboot-study
## Basic Information
- **Project Name**: ljj-springboot-study
- **Description**: jspringboot的后台增删改查业务
- **Primary Language**: Java
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 0
- **Created**: 2023-12-12
- **Last Updated**: 2024-07-25
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
### 在主项目下面新建3个模块
### 配置数据库和创建对应的数据库
### 启动项目
```
```
### 加swagger 要引入增强包
```
http://localhost:8081/swagger-ui/index.html#/
http://localhost:8081/doc.html
```
### redis
```
//需要开启两个cmd窗口来启动
redis-server.exe redis.windows.conf
redis-cli.exe -h 127.0.0.1 -p 6379
```
### ThreadLocal
```
System.out.println("当前线程id:"+Thread.currentThread().getId());
```
### jwt的权限验证处理token
```
io.jsonwebtoken
jjwt
0.9.1
```
### 跨域配置
```
@Override
public void addCorsMappings(CorsRegistry registry) {
// 设置允许跨域的路由
registry.addMapping("/**")
// 设置允许跨域请求的域名
.allowedOriginPatterns("*")
// 是否允许证书(cookies)
.allowCredentials(true)
// 设置允许的方法
.allowedMethods("*")
// 跨域允许时间
.maxAge(3600);
}
```
### 全局异常捕获
```
throw new BaseException(MessageConstant.PASSWORD_ERROR);
```
### 全局配置返回值result
```
pageResult
Result
```
### 实现登录
http://localhost:8081/admin/employee/login
### 分页器
```
PageHelper.startPage(employeePageQueryDTO.getPage(),employeePageQueryDTO.getPageSize());
```
### 日期格式的转换
```
json
扩展Spring MVC框架的消息转化器
```
### 填充公共字段
```
切面+注解
AutoFill
```
### minio文件上传
```
http://47.102.216.222:9000/
http://47.102.216.222:9005/
http://47.102.216.222:9005/lkssy-bucket/%E4%B8%91%E5%B0%8F%E9%B8%AD.jpg
```
### 支持短信验证码
### 打包 jar
```js
//在终端项目路径输入
mvn package
//在终端启动项目
java -jar xxl-spring-boot-0.0.1-SNAPSHOT.jar
```
### 集成 swagger
```
http://47.102.216.222:8081/xxl/swagger-ui/index.html#/
http://www.xxljunjun.com:8081/xxl/swagger-ui/index.html#/
https://localhost/xxl/swagger-ui/index.html#/ //默认访问https的443端口
https://www.xxljunjun.com/xxl/swagger-ui/index.html#/ //默认访问https的443端口,被docker指向容器里的443
http://localhost:8081/xxl/swagger-ui/index.html#/
http://localhost:8081/xxl/queryUserList
http://localhost:8081/xxl/hello
```
### 在阿里云申请 ssl 证书 得到秘钥
### 配置 application.yml
```yml
# 自己定义的配置项目
http:
port: 8081
# https端口号
server:
port: 443
ssl:
key-store: classpath:www.xxljunjun.com.jks
key-store-password: 6q4z5fmr
key-store-type: JKS
enabled: true
```
```java
/**
*
* @function http访问配置类
*
*/
@Configuration
public class TomcatConfig {
@Value("${http.port}")
private int httpPort;
@Bean
public WebServerFactoryCustomizer webServerFactoryCustomizer() {
return new WebServerFactoryCustomizer() {
@Override
public void customize(ConfigurableWebServerFactory factory) {
if (factory instanceof TomcatServletWebServerFactory) {
TomcatServletWebServerFactory webServerFactory = (TomcatServletWebServerFactory)factory;
Connector connector = new Connector(TomcatServletWebServerFactory.DEFAULT_PROTOCOL);
// 设置http访问的端口号,不能与https端口重复,否则会报端口被占用的错误
connector.setPort(httpPort);
webServerFactory.addAdditionalTomcatConnectors(connector);
}
}
};
}
}
```
### 配置 Dockerfile 文件
```
EXPOSE 8081 443
```
### 执行 docker 命令
```js
//要进入所在文件夹 创建镜像
docker build -t ljj-springboot-study .
//要进入所在文件夹 创建容器
docker run -d -p 8081:8081 -p 443:443 ljj-springboot-study
```