mirror of
https://github.com/201206030/novel-plus.git
synced 2025-04-26 09:20:50 +00:00
perf: 提高第一次登录速度
This commit is contained in:
parent
d9f9fd8bd2
commit
4b00ea68a9
@ -11,6 +11,7 @@ import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.net.InetAddress;
|
||||
|
||||
|
||||
@ -18,19 +19,25 @@ import java.net.InetAddress;
|
||||
@ServletComponentScan
|
||||
@MapperScan("com.java2nb.*.dao")
|
||||
@SpringBootApplication(exclude = {
|
||||
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class
|
||||
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class
|
||||
})
|
||||
@EnableCaching
|
||||
@Slf4j
|
||||
public class AdminApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AdminApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
|
||||
public CommandLineRunner commandLineRunner(ApplicationContext ctx, DataSource dataSource) {
|
||||
return args -> {
|
||||
log.info("项目启动啦,访问路径:{}", "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + ctx.getEnvironment().getProperty("server.port"));
|
||||
// 提前创建连接池,而不是在第一次访问数据库时才创建,提高第一次登录速度
|
||||
log.info("创建连接池...");
|
||||
dataSource.getConnection();
|
||||
log.info("项目启动啦,访问路径:{}",
|
||||
"http://" + InetAddress.getLocalHost().getHostAddress() + ":" + ctx.getEnvironment()
|
||||
.getProperty("server.port"));
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user