mirror of
https://github.com/201206030/novel.git
synced 2025-04-27 07:30:50 +00:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a23f4b202e | ||
|
cd3a7206a9 | ||
|
ab166a392a | ||
|
9d8709ed2d | ||
|
60488258f5 | ||
|
b7bb98db16 | ||
|
e54b656799 |
@ -40,7 +40,7 @@ novel 是一套基于时下**最新** Java 技术栈 Spring Boot 3 + Vue 3 开
|
||||
| 技术 | 版本 | 说明 | 官网 | 学习 |
|
||||
|---------------------|:------------:|-------------------------| ------------------------------------ |:------------------------------------------------------------------------------------------------------------------------:|
|
||||
| Spring Boot | 3.3.0 | 容器 + MVC 框架 | [进入](https://spring.io/projects/spring-boot) | [进入](https://docs.spring.io/spring-boot/docs/3.0.0/reference/html) |
|
||||
| Spring AI | 1.0.0-SNAPSHOT | Spring 官方 AI 框架 | [进入](https://spring.io/projects/spring-ai) | [进入](https://docs.spring.io/spring-ai/reference/) |
|
||||
| Spring AI | 1.0.0-M6 | Spring 官方 AI 框架 | [进入](https://spring.io/projects/spring-ai) | [进入](https://docs.spring.io/spring-ai/reference/) |
|
||||
| MyBatis | 3.5.9 | ORM 框架 | [进入](http://www.mybatis.org) | [进入](https://mybatis.org/mybatis-3/zh/index.html) |
|
||||
| MyBatis-Plus | 3.5.3 | MyBatis 增强工具 | [进入](https://baomidou.com/) | [进入](https://baomidou.com/pages/24112f/) |
|
||||
| JJWT | 0.11.5 | JWT 登录支持 | [进入](https://github.com/jwtk/jjwt) | - |
|
||||
|
20
pom.xml
20
pom.xml
@ -11,7 +11,7 @@
|
||||
</parent>
|
||||
<groupId>io.github.xxyopen</groupId>
|
||||
<artifactId>novel</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<version>3.5.1-SNAPSHOT</version>
|
||||
<name>novel</name>
|
||||
<description>Spring Boot 3 + Vue 3 构建的前后端分离小说系统</description>
|
||||
<properties>
|
||||
@ -223,7 +223,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-bom</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>1.0.0-M6</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
@ -266,22 +266,6 @@
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.github.xxyopen.novel;
|
||||
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
@ -14,6 +15,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.util.Map;
|
||||
|
||||
@SpringBootApplication
|
||||
@ -28,7 +31,7 @@ public class NovelApplication {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CommandLineRunner commandLineRunner(ApplicationContext context) {
|
||||
public CommandLineRunner commandLineRunner(ApplicationContext context, DataSource dataSource) {
|
||||
return args -> {
|
||||
Map<String, CacheManager> beans = context.getBeansOfType(CacheManager.class);
|
||||
log.info("加载了如下缓存管理器:");
|
||||
@ -36,7 +39,17 @@ public class NovelApplication {
|
||||
log.info("{}:{}", k, v.getClass().getName());
|
||||
log.info("缓存:{}", v.getCacheNames());
|
||||
});
|
||||
|
||||
if(dataSource instanceof HikariDataSource hikariDataSource) {
|
||||
// 如果使用的是HikariDataSource,需要提前创建连接池,而不是在第一次访问数据库时才创建,提高第一次访问接口的速度
|
||||
log.info("创建连接池...");
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
log.info("最小空闲连接数:{}", hikariDataSource.getMinimumIdle());
|
||||
log.info("最大连接数:{}", hikariDataSource.getMaximumPoolSize());
|
||||
log.info("创建连接池完成.");
|
||||
log.info("数据库:{}", connection.getMetaData().getDatabaseProductName());
|
||||
log.info("数据库版本:{}", connection.getMetaData().getDatabaseProductVersion());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -3,9 +3,12 @@ package io.github.xxyopen.novel.core.common.exception;
|
||||
import io.github.xxyopen.novel.core.common.constant.ErrorCodeEnum;
|
||||
import io.github.xxyopen.novel.core.common.resp.RestResp;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.servlet.resource.NoResourceFoundException;
|
||||
|
||||
/**
|
||||
* 通用的异常处理器
|
||||
@ -17,6 +20,15 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
@RestControllerAdvice
|
||||
public class CommonExceptionHandler {
|
||||
|
||||
/**
|
||||
* 处理404异常
|
||||
*/
|
||||
@ExceptionHandler(NoResourceFoundException.class)
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
public String handlerNotFound() {
|
||||
return "404";
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理数据校验异常
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user