更新docker-compose一键部署,修正部分bug
This commit is contained in:
parent
bc2d690656
commit
cd29ec2f5e
|
@ -22,6 +22,7 @@
|
|||
| 2021-05-09 | 添加公共讨论区,题目讨论区,比赛评论 | Himit_ZH |
|
||||
| 2021-05-12 | 添加评论及回复删除,讨论举报,调整显示时间。 | Himit_ZH |
|
||||
| 2021-05-16 | 完善权限控制,讨论管理员管理,讨论删除与编辑更新。 | Himit_ZH |
|
||||
| 2021-05-22 | 更新docker-compose一键部署,修正部分bug | Himit_ZH |
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
# 环境配置
|
||||
|
||||
## 写在前面
|
||||
|
||||
> 本次部署基于部署人员熟悉springboot与vue的打包,下次有空再将对应的前后端打包成镜像,使用docker一键部署就比较方便
|
||||
> **但目前只能"享受"一步步部署的乐趣**
|
||||
|
||||
## 环境说明
|
||||
|
||||
- 后端:需要在Linux系统下部署运行,建议使用ubuntu18.04,其它版本的Linux系统也可,同时需要**Docker**辅助部署
|
||||
|
@ -12,39 +7,12 @@
|
|||
- 判题服务:由于判题沙盒有多操作系统版本,Linux系统或Windows都可,强烈建议Linux系统(Ubuntu)
|
||||
- 数据同步:需要运行判题服务和后端服务的服务器有rsync即可
|
||||
|
||||
## Linux服务器环境搭建
|
||||
## Linux环境搭建
|
||||
|
||||
> 请先准备一台 CPU: 1核 内存: 2G 硬盘: 30G的云服务器,推荐Ubuntu16.04以上的操作系统,
|
||||
>
|
||||
> HOJ使用的Ubuntu18.04版本
|
||||
|
||||
### 安装nginx
|
||||
|
||||
> 注意:apt下载太慢的话,建议换阿里云源,请自行百度or谷歌
|
||||
|
||||
1. 使用apt安装
|
||||
|
||||
```shell
|
||||
sudo apt install nginx
|
||||
```
|
||||
|
||||
2. 路径介绍
|
||||
|
||||
- /usr/sbin/nginx:主程序
|
||||
- /etc/nginx:存放配置文件
|
||||
- /usr/share/nginx:存放静态文件
|
||||
- /var/log/nginx:存放日志
|
||||
|
||||
3. 启动nginx
|
||||
|
||||
```shell
|
||||
service nginx start
|
||||
```
|
||||
|
||||
4. 验证是否成功
|
||||
|
||||
在浏览器输入你的ip地址,如果出现Wellcome to nginx 那么就是配置成功。
|
||||
|
||||
### 安装docker
|
||||
|
||||
1. 安装需要的包
|
||||
|
@ -92,5 +60,101 @@
|
|||
sudo docker run hello-world
|
||||
```
|
||||
|
||||
### 安装docker-compose
|
||||
|
||||
1. 下载
|
||||
|
||||
```shell
|
||||
sudo curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.5/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
|
||||
```
|
||||
|
||||
2. 授权
|
||||
|
||||
```shell
|
||||
sudo chmod +x /usr/local/bin/docker-compose
|
||||
```
|
||||
|
||||
## Windows 环境
|
||||
|
||||
Windows 下的安装仅供体验,勿在生产环境使用。如有必要,请使用虚拟机安装 Linux 并将 OJ 安装在其中。
|
||||
|
||||
以下教程仅适用于 Win10 x64 下的 `PowerShell`
|
||||
|
||||
1. 安装 Windows 的 Docker 工具
|
||||
2. 右击右下角 Docker 图标,选择 Settings 进行设置
|
||||
3. 选择 `Shared Drives` 菜单,之后勾选你想安装 OJ 的盘符位置(例如勾选D盘),点击 `Apply`
|
||||
4. 输入 Windows 的账号密码进行文件共享
|
||||
5. 安装 `Python`、`pip`、`git`、`docker-compose`,安装方法自行搜索。
|
||||
|
||||
|
||||
|
||||
## docker-compose开始部署
|
||||
|
||||
1. 选择好需要安装的位置,运行下面命令
|
||||
|
||||
```shell
|
||||
git clone https://gitee.com/himitzh0730/hoj-deploy.git && cd hoj-deploy
|
||||
```
|
||||
|
||||
2. 单机部署(建议服务器内存2G以上)
|
||||
|
||||
> 注意:以下操作建议试用,配置大部分是默认的,实际运行请修改`docker-compose.yml`文件的配置
|
||||
|
||||
```shell
|
||||
cd standAlone && docker-compose up -d
|
||||
```
|
||||
|
||||
根据网速情况,大约十到二十分钟即可安装完毕,全程无需人工干预。
|
||||
|
||||
等待命令执行完毕后,查看容器状态
|
||||
|
||||
```shell
|
||||
docker ps -a
|
||||
```
|
||||
|
||||
当看到所有的容器的状态status都为`UP`就代表 OJ 已经启动成功。
|
||||
|
||||
> 以下默认参数说明
|
||||
|
||||
- 默认超级管理员账号与密码:root / hoj123456
|
||||
- 默认redis密码:hoj123456
|
||||
- 默认mysql账号与密码:root / hoj123456
|
||||
- 默认nacos管理员账号与密码:root / hoj123456
|
||||
- 默认不开启https,开启需修改文件同时提供证书文件
|
||||
- 判题并发数默认:cpu核心数*2
|
||||
- 默认开启vj判题,需要手动修改添加账号与密码,如果不添加不能vj判题!
|
||||
- vj判题并发数默认:cpu核心数*4
|
||||
|
||||
**登录root账号到后台查看服务状态以及到`http://ip/admin/conf`修改服务配置!**
|
||||
|
||||
<u>注意:网站的注册及用户账号相关操作需要邮件系统,所以请在系统配置中配置自己的邮件服务。</u>
|
||||
|
||||
3. 分布式部署(默认开启rsync数据同步)
|
||||
|
||||
- 主服务启动,默认不提供判题服务,请修改该启动文件配置
|
||||
|
||||
```shell
|
||||
cd distributed/main
|
||||
vim docker-compose.yml # 请根据文件内注释提示修改
|
||||
```
|
||||
|
||||
配置修改保存后,在`docker-compose.yml`当前路径下启动该服务
|
||||
|
||||
```shell
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
- 判题服务启动,请修改该启动文件配置
|
||||
|
||||
```shell
|
||||
cd distributed/judgeserver
|
||||
vim docker-compose.yml # 请根据文件内注释提示修改
|
||||
```
|
||||
|
||||
配置修改保存后,在`docker-compose.yml`当前路径下启动该服务
|
||||
|
||||
```shell
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
两个服务都启动完成,在浏览器输入主服务ip或域名进行访问,登录root账号到后台查看服务状态以及到`http://ip/admin/conf`修改服务配置!
|
|
@ -1,51 +1,16 @@
|
|||
# 后端部署
|
||||
|
||||
### 安装MySQL
|
||||
首先 先下载[hoj-deploy](https://gitee.com/himitzh0730/hoj-deploy/tree/master)
|
||||
|
||||
1. 创建自定义网络(用于容器通讯)
|
||||
```shell
|
||||
git clone git@gitee.com:himitzh0730/hoj-deploy.git
|
||||
```
|
||||
|
||||
```shell
|
||||
docker network create --subnet=172.18.0.0/16 hoj-network
|
||||
```
|
||||
### 一、MySQL部署
|
||||
|
||||
2. 查看网络
|
||||
|
||||
|
||||
```shell
|
||||
docker network ls
|
||||
```
|
||||
|
||||
3. 创建挂载文件夹
|
||||
|
||||
```shell
|
||||
//mysql配置文件
|
||||
mkdir -p /hoj/data/mysql/conf
|
||||
//mysql数据文件路径
|
||||
mkdir –p /hoj/data/mysql/data
|
||||
```
|
||||
|
||||
4. 启动mysql
|
||||
|
||||
`MYSQL_ROOT_PASSWORD`为mysql数据库root用户的密码,可自行修改。
|
||||
|
||||
```shell
|
||||
docker run -p 3306:3306 --name mysql -d \
|
||||
--restart=always \
|
||||
--network hoj-network \
|
||||
--ip 172.18.0.2 \
|
||||
--restart="always" \
|
||||
-v /hoj/data/mysql/conf.d:/etc/mysql/conf.d \
|
||||
-v /hoj/data/mysql/data:/var/lib/mysql \
|
||||
-e MYSQL_ROOT_PASSWORD="123456" \
|
||||
mysql:5.7
|
||||
```
|
||||
|
||||
5. 启动成功后 使用docker ps 可查看 如果正常则进行下面操作.
|
||||
|
||||
6. 在本地使用链接MySQL数据库的工具例如Navicat,SQLyog等连上云服务器docker运行的MySQL,进行第6,第7步操作。
|
||||
|
||||
7. 创建名字叫hoj的数据库,然后执行脚本在HOJ总项目的sqlAndSetting文件夹里面或者 [hoj.sql](https://gitee.com/himitzh0730/hoj/blob/master/sqlAndsetting/hoj.sql)、[hoj-data.sql](https://gitee.com/himitzh0730/hoj/blob/master/sqlAndsetting/hoj-data.sql)
|
||||
|
||||
8. 创建名字叫nacos的数据库,然后执行脚本在HOJ总项目的sqlAndSetting文件夹里面或者 [nacos.sql](https://gitee.com/himitzh0730/hoj/blob/master/sqlAndsetting/nacos-mysql.sql)
|
||||
1. 进入到文件
|
||||
|
||||
### 安装Nacos
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="api" />
|
||||
<module name="DataBackup" />
|
||||
<module name="JudgeServer" />
|
||||
<module name="DataBackup" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,65 @@
|
|||
package top.hcode.hoj.config;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @Author: Himit_ZH
|
||||
* @Date: 2021/5/21 17:57
|
||||
* @Description:
|
||||
*/
|
||||
@Configuration
|
||||
@RefreshScope
|
||||
@Data
|
||||
public class DruidConfiguration {
|
||||
|
||||
@Value("${hoj.db.username:${MYSQL_USERNAME:root}}")
|
||||
private String username;
|
||||
|
||||
@Value("${hoj.db.password:${MYSQL_ROOT_PASSWORD:hoj123456}}")
|
||||
private String password;
|
||||
|
||||
@Value("${hoj.db.host:${MYSQL_HOST:172.20.0.3}}")
|
||||
private String host;
|
||||
|
||||
@Value("${hoj.db.port:${MYSQL_PORT:3306}}")
|
||||
private Integer port;
|
||||
|
||||
@Value("${hoj.db.name:${MYSQL_DATABASE_NAME:hoj}}")
|
||||
private String name;
|
||||
|
||||
@Value("${spring.datasource.driver-class-name}")
|
||||
private String driverClassName;
|
||||
|
||||
@Value("${spring.datasource.initial-size}")
|
||||
private Integer initialSize;
|
||||
|
||||
@Value("${spring.datasource.min-idle}")
|
||||
private Integer minIdle;
|
||||
|
||||
@Value("${spring.datasource.maxActive}")
|
||||
private Integer maxActive;
|
||||
|
||||
@Value("${spring.datasource.maxWait}")
|
||||
private Integer maxWait;
|
||||
|
||||
@Bean(name = "datasource")
|
||||
@RefreshScope
|
||||
public DruidDataSource dataSource() {
|
||||
DruidDataSource datasource = new DruidDataSource();
|
||||
String url = "jdbc:mysql://" + host + ":" + port + "/" + name + "?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true";
|
||||
datasource.setUrl(url);
|
||||
datasource.setUsername(username);
|
||||
datasource.setPassword(password);
|
||||
datasource.setDriverClassName(driverClassName);
|
||||
datasource.setMaxActive(maxActive);
|
||||
datasource.setInitialSize(initialSize);
|
||||
datasource.setMinIdle(minIdle);
|
||||
datasource.setMaxWait(maxWait);
|
||||
return datasource;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package top.hcode.hoj.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.RedisPassword;
|
||||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
|
||||
/**
|
||||
* @Author: Himit_ZH
|
||||
* @Date: 2021/5/21 15:53
|
||||
* @Description:
|
||||
*/
|
||||
@Configuration
|
||||
public class RedisAutoConfig {
|
||||
|
||||
@Bean
|
||||
public RedisConnectionFactory redisConnectionFactory(JedisPoolConfig jedisPool,
|
||||
RedisStandaloneConfiguration jedisConfig) {
|
||||
JedisConnectionFactory connectionFactory = new JedisConnectionFactory(jedisConfig);
|
||||
connectionFactory.setPoolConfig(jedisPool);
|
||||
return connectionFactory;
|
||||
}
|
||||
|
||||
@Configuration
|
||||
public static class JedisConf {
|
||||
@Value("${spring.redis.host:172.20.0.2}")
|
||||
private String host;
|
||||
@Value("${spring.redis.port:6379}")
|
||||
private Integer port;
|
||||
@Value("${spring.redis.password:hoj123456}")
|
||||
private String password;
|
||||
|
||||
@Value("${spring.redis.jedis.pool.max-active:200}")
|
||||
private Integer maxActive;
|
||||
@Value("${spring.redis.jedis.pool.max-idle:50}")
|
||||
private Integer maxIdle;
|
||||
@Value("${spring.redis.jedis.pool.max-wait:-1}")
|
||||
private Long maxWait;
|
||||
@Value("${spring.redis.jedis.pool.min-idle:10}")
|
||||
private Integer minIdle;
|
||||
|
||||
@Bean
|
||||
public JedisPoolConfig jedisPool() {
|
||||
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
|
||||
jedisPoolConfig.setMaxIdle(maxIdle);
|
||||
jedisPoolConfig.setMaxWaitMillis(maxWait);
|
||||
jedisPoolConfig.setMaxTotal(maxActive);
|
||||
jedisPoolConfig.setMinIdle(minIdle);
|
||||
return jedisPoolConfig;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RedisStandaloneConfiguration jedisConfig() {
|
||||
RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
|
||||
config.setHostName(host);
|
||||
config.setPort(port);
|
||||
config.setPassword(RedisPassword.of(password));
|
||||
return config;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -43,7 +43,6 @@ public class ShiroConfig {
|
|||
@Autowired
|
||||
JwtFilter jwtFilter;
|
||||
|
||||
|
||||
@Bean
|
||||
public SessionManager sessionManager(RedisSessionDAO redisSessionDAO) {
|
||||
DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
|
||||
|
@ -52,7 +51,6 @@ public class ShiroConfig {
|
|||
}
|
||||
|
||||
|
||||
|
||||
@Bean
|
||||
public DefaultWebSecurityManager securityManager(AccountRealm accountRealm,
|
||||
SessionManager sessionManager,
|
||||
|
|
|
@ -7,6 +7,8 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.context.EnvironmentAware;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Component;
|
||||
import top.hcode.hoj.pojo.entity.RemoteJudgeAccount;
|
||||
import top.hcode.hoj.pojo.vo.ConfigVo;
|
||||
|
@ -33,79 +35,78 @@ public class StartupRunner implements CommandLineRunner {
|
|||
@Autowired
|
||||
private RemoteJudgeAccountServiceImpl remoteJudgeAccountService;
|
||||
|
||||
@Value("${hoj-backstage.open-remote-judge}")
|
||||
@Value("${OPEN_REMOTE_JUDGE:true}")
|
||||
private String openRemoteJudge;
|
||||
|
||||
// jwt配置
|
||||
@Value("${hoj-backstage.config.jwt.secret}")
|
||||
@Value("${JWT_TOKEN_SECRET:default}")
|
||||
private String tokenSecret;
|
||||
|
||||
@Value("${hoj-backstage.config.jwt.expire}")
|
||||
@Value("${JWT_TOKEN_EXPIRE:86400}")
|
||||
private String tokenExpire;
|
||||
|
||||
@Value("${hoj-backstage.config.jwt.checkRefreshExpire}")
|
||||
@Value("${JWT_TOKEN_FRESH_EXPIRE:43200}")
|
||||
private String checkRefreshExpire;
|
||||
|
||||
// 数据库配置
|
||||
@Value("${hoj-backstage.config.db.username}")
|
||||
@Value("${MYSQL_USERNAME:root}")
|
||||
private String mysqlUsername;
|
||||
|
||||
@Value("${hoj-backstage.config.db.password}")
|
||||
@Value("${MYSQL_ROOT_PASSWORD:hoj123456}")
|
||||
private String mysqlPassword;
|
||||
|
||||
@Value("${hoj-backstage.config.db.name}")
|
||||
@Value("${MYSQL_DATABASE_NAME:hoj}")
|
||||
private String mysqlDBName;
|
||||
|
||||
@Value("${hoj-backstage.config.db.host}")
|
||||
@Value("${MYSQL_HOST:172.20.0.3}")
|
||||
private String mysqlHost;
|
||||
|
||||
@Value("${hoj-backstage.config.db.public-host}")
|
||||
@Value("${MYSQL_PUBLIC_HOST:172.20.0.3}")
|
||||
private String mysqlPublicHost;
|
||||
|
||||
@Value("${hoj-backstage.config.db.port}")
|
||||
@Value("${MYSQL_PORT:3306}")
|
||||
private Integer mysqlPort;
|
||||
|
||||
// 缓存配置
|
||||
@Value("${hoj-backstage.config.redis.host}")
|
||||
@Value("${REDIS_HOST:172.20.0.2}")
|
||||
private String redisHost;
|
||||
|
||||
@Value("${hoj-backstage.config.redis.port}")
|
||||
@Value("${REDIS_PORT:6379}")
|
||||
private Integer redisPort;
|
||||
|
||||
@Value("${hoj-backstage.config.redis.password}")
|
||||
@Value("${REDIS_PASSWORD:hoj123456}")
|
||||
private String redisPassword;
|
||||
// 判题服务token
|
||||
@Value("${hoj-backstage.config.judge.token}")
|
||||
@Value("${JUDGE_TOKEN:default}")
|
||||
private String judgeToken;
|
||||
|
||||
// 邮箱配置
|
||||
@Value("${hoj-backstage.config.mail.username}")
|
||||
@Value("${EMAIL_USERNAME:your_email_username}")
|
||||
private String emailUsername;
|
||||
|
||||
@Value("${hoj-backstage.config.mail.password}")
|
||||
@Value("${EMAIL_PASSWORD:your_email_password}")
|
||||
private String emailPassword;
|
||||
|
||||
@Value("${hoj-backstage.config.mail.host}")
|
||||
@Value("${EMAIL_SERVER_HOST:your_email_host}")
|
||||
private String emailHost;
|
||||
|
||||
@Value("${hoj-backstage.config.mail.port}")
|
||||
@Value("${EMAIL_SERVER_PORT:465}")
|
||||
private Integer emailPort;
|
||||
|
||||
@Value("${hoj-backstage.config.hdu.account.username}")
|
||||
@Value("${HDU_ACCOUNT_USERNAME_LIST:}")
|
||||
private List<String> hduUsernameList;
|
||||
|
||||
@Value("${hoj-backstage.config.hdu.account.password}")
|
||||
@Value("${HDU_ACCOUNT_PASSWORD_LIST:}")
|
||||
private List<String> hduPasswordList;
|
||||
|
||||
@Value("${hoj-backstage.config.cf.account.username}")
|
||||
@Value("${CF_ACCOUNT_USERNAME_LIST:}")
|
||||
private List<String> cfUsernameList;
|
||||
|
||||
@Value("${hoj-backstage.config.cf.account.password}")
|
||||
@Value("${CF_ACCOUNT_PASSWORD_LIST:}")
|
||||
private List<String> cfPasswordList;
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
System.out.println(openRemoteJudge);
|
||||
if (openRemoteJudge.equals("true")) {
|
||||
addRemoteJudgeAccountToRedis();
|
||||
}
|
||||
|
|
|
@ -104,10 +104,10 @@ public class AdminJudgeController {
|
|||
// 调用判题服务
|
||||
Problem problem = problemService.getById(judge.getPid());
|
||||
if (problem.getIsRemote()) { // 如果是远程oj判题
|
||||
remoteJudgeDispatcher.sendTask(judge.getSubmitId(), judge.getPid(), judgeToken, problem.getProblemId(),
|
||||
remoteJudgeDispatcher.sendTask(judge, judgeToken, problem.getProblemId(),
|
||||
judge.getCid() != 0, 1);
|
||||
} else {
|
||||
judgeDispatcher.sendTask(judge.getSubmitId(), judge.getPid(), judgeToken, judge.getCid() != 0, 1);
|
||||
judgeDispatcher.sendTask(judge, judgeToken, judge.getCid() != 0, 1);
|
||||
}
|
||||
return CommonResult.successResponse(judge, "重判成功!该提交已进入判题队列!");
|
||||
} else {
|
||||
|
@ -154,13 +154,13 @@ public class AdminJudgeController {
|
|||
if (problem.getIsRemote()) { // 如果是远程oj判题
|
||||
for (Judge judge : rejudgeList) {
|
||||
// 进入重判队列,等待调用判题服务
|
||||
remoteJudgeDispatcher.sendTask(judge.getSubmitId(), judge.getPid(), judgeToken, problem.getProblemId(),
|
||||
remoteJudgeDispatcher.sendTask(judge, judgeToken, problem.getProblemId(),
|
||||
judge.getCid() != 0, 1);
|
||||
}
|
||||
} else {
|
||||
for (Judge judge : rejudgeList) {
|
||||
// 进入重判队列,等待调用判题服务
|
||||
judgeDispatcher.sendTask(judge.getSubmitId(), judge.getPid(), judgeToken, judge.getCid() != 0, 1);
|
||||
judgeDispatcher.sendTask(judge, judgeToken, judge.getCid() != 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -211,11 +211,10 @@ public class JudgeController {
|
|||
|
||||
// 将提交加入任务队列
|
||||
if (judgeDto.getIsRemote()) { // 如果是远程oj判题
|
||||
remoteJudgeDispatcher.sendTask(judge.getSubmitId(), judge.getPid(), judgeToken, judge.getDisplayPid(),
|
||||
judge.getCid() != 0, 1);
|
||||
remoteJudgeDispatcher.sendTask(judge, judgeToken, judge.getDisplayPid(), judge.getCid() != 0, 1);
|
||||
|
||||
} else {
|
||||
judgeDispatcher.sendTask(judge.getSubmitId(), judge.getPid(), judgeToken, judge.getCid() == 0, 1);
|
||||
judgeDispatcher.sendTask(judge, judgeToken, judge.getCid() == 0, 1);
|
||||
}
|
||||
|
||||
return CommonResult.successResponse(judge, "代码提交成功!");
|
||||
|
@ -274,11 +273,10 @@ public class JudgeController {
|
|||
judgeService.updateById(judge);
|
||||
// 将提交加入任务队列
|
||||
if (problem.getIsRemote()) { // 如果是远程oj判题
|
||||
remoteJudgeDispatcher.sendTask(judge.getSubmitId(), judge.getPid(), judgeToken, problem.getProblemId(),
|
||||
remoteJudgeDispatcher.sendTask(judge, judgeToken, problem.getProblemId(),
|
||||
judge.getCid() != 0, 1);
|
||||
} else {
|
||||
judgeDispatcher.sendTask(judge.getSubmitId(), judge.getPid(), judgeToken,
|
||||
judge.getCid() != 0, 1);
|
||||
judgeDispatcher.sendTask(judge, judgeToken, judge.getCid() != 0, 1);
|
||||
}
|
||||
return CommonResult.successResponse(judge, "重新提交成功!");
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class JudgeServerUtils {
|
|||
switch (type) {
|
||||
case "judge":
|
||||
ToJudge judgeData = (ToJudge) data;
|
||||
toJudge(path, (ToJudge) data, judgeData.getJudge().getSubmitId(), judgeData.getRemoteJudge() != null);
|
||||
toJudge(path, judgeData, judgeData.getJudge().getSubmitId(), judgeData.getRemoteJudge() != null);
|
||||
break;
|
||||
case "compile":
|
||||
CompileSpj compileSpj = (CompileSpj) data;
|
||||
|
|
|
@ -25,10 +25,9 @@ public class RemoteJudgeDispatcher {
|
|||
@Autowired
|
||||
private RemoteJudgeReceiver remoteJudgeReceiver;
|
||||
|
||||
public void sendTask(Long submitId, Long pid, String token, String remoteJudge, Boolean isContest, Integer tryAgainNum) {
|
||||
public void sendTask(Judge judge, String token, String remoteJudge, Boolean isContest, Integer tryAgainNum) {
|
||||
JSONObject task = new JSONObject();
|
||||
task.set("submitId", submitId);
|
||||
task.set("pid", pid);
|
||||
task.set("judge", judge);
|
||||
task.set("remoteJudge", remoteJudge);
|
||||
task.set("token", token);
|
||||
task.set("isContest", isContest);
|
||||
|
@ -37,16 +36,16 @@ public class RemoteJudgeDispatcher {
|
|||
boolean isOk = redisUtils.llPush(Constants.Judge.STATUS_REMOTE_JUDGE_WAITING_HANDLE.getName(), JSONUtil.toJsonStr(task));
|
||||
if (!isOk) {
|
||||
judgeService.updateById(new Judge()
|
||||
.setSubmitId(submitId)
|
||||
.setSubmitId(judge.getSubmitId())
|
||||
.setStatus(Constants.Judge.STATUS_SUBMITTED_FAILED.getStatus())
|
||||
.setErrorMessage("Please try to submit again!")
|
||||
);
|
||||
}else{
|
||||
remoteJudgeReceiver.processWaitingTask();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("调用redis将判题纳入判题等待队列异常,此次判题任务判为系统错误--------------->{}", e.getMessage());
|
||||
judgeService.failToUseRedisPublishJudge(submitId, pid, isContest);
|
||||
}finally {
|
||||
remoteJudgeReceiver.processWaitingTask();
|
||||
judgeService.failToUseRedisPublishJudge(judge.getSubmitId(), judge.getPid(), isContest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,9 +59,8 @@ public class RemoteJudgeReceiver {
|
|||
|
||||
JSONObject task = JSONUtil.parseObj(taskJsonStr);
|
||||
|
||||
Long submitId = task.getLong("submitId");
|
||||
Judge judge = task.get("judge", Judge.class);
|
||||
String token = task.getStr("token");
|
||||
Long pid = task.getLong("pid");
|
||||
String remoteJudge = task.getStr("remoteJudge");
|
||||
Boolean isContest = task.getBool("isContest");
|
||||
Integer tryAgainNum = task.getInt("tryAgainNum");
|
||||
|
@ -88,8 +87,6 @@ public class RemoteJudgeReceiver {
|
|||
}
|
||||
|
||||
if (account != null) { // 如果获取到账号
|
||||
|
||||
Judge judge = judgeService.getById(submitId);
|
||||
// 调用判题服务
|
||||
judgeServerUtils.dispatcher("judge", "/remote-judge", new ToJudge()
|
||||
.setJudge(judge)
|
||||
|
@ -107,13 +104,11 @@ public class RemoteJudgeReceiver {
|
|||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
remoteJudgeDispatcher.sendTask(submitId, pid, token, remoteJudge, isContest, tryAgainNum + 1);
|
||||
remoteJudgeDispatcher.sendTask(judge, token, remoteJudge, isContest, tryAgainNum + 1);
|
||||
}
|
||||
} else {
|
||||
if (tryAgainNum >= 30) {
|
||||
// 获取调用多次失败可能为系统忙碌,判为提交失败
|
||||
Judge judge = new Judge();
|
||||
judge.setSubmitId(submitId);
|
||||
judge.setStatus(Constants.Judge.STATUS_SUBMITTED_FAILED.getStatus());
|
||||
judge.setErrorMessage("Failed to connect the judgeServer. Please resubmit this submission again!");
|
||||
judgeService.updateById(judge);
|
||||
|
@ -124,7 +119,7 @@ public class RemoteJudgeReceiver {
|
|||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
remoteJudgeDispatcher.sendTask(submitId, pid, token, remoteJudge, isContest, tryAgainNum + 1);
|
||||
remoteJudgeDispatcher.sendTask(judge, token, remoteJudge, isContest, tryAgainNum + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,29 +29,27 @@ public class JudgeDispatcher {
|
|||
@Autowired
|
||||
private JudgeReceiver judgeReceiver;
|
||||
|
||||
public void sendTask(Long submitId, Long pid, String token, Boolean isContest, Integer tryAgainNum) {
|
||||
public void sendTask(Judge judge, String token, Boolean isContest, Integer tryAgainNum) {
|
||||
JSONObject task = new JSONObject();
|
||||
task.set("submitId", submitId);
|
||||
task.set("pid", pid);
|
||||
task.set("judge", judge);
|
||||
task.set("token", token);
|
||||
task.set("isContest", isContest);
|
||||
task.set("tryAgainNum", tryAgainNum);
|
||||
|
||||
try {
|
||||
boolean isOk = redisUtils.llPush(Constants.Judge.STATUS_JUDGE_WAITING.getName(), JSONUtil.toJsonStr(task));
|
||||
if (!isOk) {
|
||||
judgeService.updateById(new Judge()
|
||||
.setSubmitId(submitId)
|
||||
.setSubmitId(judge.getSubmitId())
|
||||
.setStatus(Constants.Judge.STATUS_SUBMITTED_FAILED.getStatus())
|
||||
.setErrorMessage("Please try to submit again!")
|
||||
);
|
||||
} else {
|
||||
// 调用判题任务处理
|
||||
judgeReceiver.processWaitingTask();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("调用redis将判题纳入判题等待队列异常,此次判题任务判为系统错误--------------->{}", e.getMessage());
|
||||
judgeService.failToUseRedisPublishJudge(submitId, pid, isContest);
|
||||
} finally {
|
||||
// 调用判题任务处理
|
||||
judgeReceiver.processWaitingTask();
|
||||
judgeService.failToUseRedisPublishJudge(judge.getSubmitId(), judge.getPid(), isContest);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,9 +30,6 @@ public class JudgeReceiver {
|
|||
@Autowired
|
||||
private RedisUtils redisUtils;
|
||||
|
||||
@Autowired
|
||||
private JudgeServiceImpl judgeService;
|
||||
|
||||
@Async
|
||||
public void processWaitingTask() {
|
||||
// 如果队列中还有任务,则继续处理
|
||||
|
@ -45,13 +42,12 @@ public class JudgeReceiver {
|
|||
}
|
||||
}
|
||||
|
||||
private void handleJudgeMsg(String taskJsonStr) {
|
||||
public void handleJudgeMsg(String taskJsonStr) {
|
||||
|
||||
JSONObject task = JSONUtil.parseObj(taskJsonStr);
|
||||
Long submitId = task.getLong("submitId");
|
||||
Judge judge = task.get("judge", Judge.class);
|
||||
String token = task.getStr("token");
|
||||
Integer tryAgainNum = task.getInt("tryAgainNum");
|
||||
Judge judge = judgeService.getById(submitId);
|
||||
|
||||
// 调用判题服务
|
||||
judgeServerUtils.dispatcher("judge", "/judge", new ToJudge()
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -19,6 +20,7 @@ import top.hcode.hoj.utils.Constants;
|
|||
import javax.mail.MessagingException;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -32,8 +34,6 @@ import java.util.Date;
|
|||
@Slf4j(topic = "hoj")
|
||||
public class EmailServiceImpl implements EmailService {
|
||||
|
||||
@Autowired
|
||||
private JavaMailSender mailSender;
|
||||
|
||||
@Autowired
|
||||
private TemplateEngine templateEngine;
|
||||
|
@ -53,6 +53,42 @@ public class EmailServiceImpl implements EmailService {
|
|||
@Value("${hoj.mail.username}")
|
||||
public String ojEmailFrom;
|
||||
|
||||
@Value("${hoj.mail.password}")
|
||||
public String ojEmailPassword;
|
||||
|
||||
@Value("${hoj.mail.host}")
|
||||
public String ojEmailHost;
|
||||
|
||||
@Value("${hoj.mail.port}")
|
||||
public Integer ojEmailPort;
|
||||
|
||||
@Value("${hoj.mail.ssl}")
|
||||
public String ojEmailSsl;
|
||||
|
||||
/**
|
||||
* @MethodName getMailSender
|
||||
* @Params * @param
|
||||
* @Description 获取邮件系统配置
|
||||
* @Return
|
||||
* @Since 2021/5/21
|
||||
*/
|
||||
private JavaMailSenderImpl getMailSender() {
|
||||
|
||||
JavaMailSenderImpl sender = new JavaMailSenderImpl();
|
||||
sender.setHost(ojEmailHost);
|
||||
sender.setPort(ojEmailPort);
|
||||
sender.setDefaultEncoding("UTF-8");
|
||||
sender.setUsername(ojEmailFrom);
|
||||
sender.setPassword(ojEmailPassword);
|
||||
|
||||
Properties p = new Properties();
|
||||
p.setProperty("mail.smtp.ssl.enable", ojEmailSsl);
|
||||
p.setProperty("mail.smtp.auth", "true");
|
||||
p.setProperty("mail.smtp.starttls.enable", ojEmailSsl);
|
||||
sender.setJavaMailProperties(p);
|
||||
return sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param email 用户邮箱
|
||||
* @param code 生成的六位随机数字验证码
|
||||
|
@ -64,6 +100,7 @@ public class EmailServiceImpl implements EmailService {
|
|||
@Override
|
||||
public void sendCode(String email, String code) {
|
||||
DateTime expireTime = DateUtil.offsetMinute(new Date(), 10);
|
||||
JavaMailSenderImpl mailSender = getMailSender();
|
||||
MimeMessage mimeMessage = mailSender.createMimeMessage();
|
||||
try {
|
||||
MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage,
|
||||
|
@ -79,6 +116,9 @@ public class EmailServiceImpl implements EmailService {
|
|||
|
||||
//利用模板引擎加载html文件进行渲染并生成对应的字符串
|
||||
String emailContent = templateEngine.process("emailTemplate_registerCode", context);
|
||||
|
||||
JavaMailSenderImpl sender = new JavaMailSenderImpl();
|
||||
|
||||
// 设置邮件标题
|
||||
mimeMessageHelper.setSubject("HOJ的注册邮件");
|
||||
mimeMessageHelper.setText(emailContent, true);
|
||||
|
@ -86,6 +126,7 @@ public class EmailServiceImpl implements EmailService {
|
|||
mimeMessageHelper.setTo(email);
|
||||
// 发送人
|
||||
mimeMessageHelper.setFrom(ojEmailFrom);
|
||||
|
||||
mailSender.send(mimeMessage);
|
||||
} catch (MessagingException e) {
|
||||
log.error("用户注册的邮件任务发生异常------------>{}", e.getMessage());
|
||||
|
@ -105,6 +146,7 @@ public class EmailServiceImpl implements EmailService {
|
|||
@Override
|
||||
public void sendResetPassword(String username, String code, String email) {
|
||||
DateTime expireTime = DateUtil.offsetMinute(new Date(), 10);
|
||||
JavaMailSenderImpl mailSender = getMailSender();
|
||||
MimeMessage mimeMessage = mailSender.createMimeMessage();
|
||||
try {
|
||||
MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage,
|
||||
|
@ -145,6 +187,7 @@ public class EmailServiceImpl implements EmailService {
|
|||
*/
|
||||
@Override
|
||||
public void testEmail(String email) {
|
||||
JavaMailSenderImpl mailSender = getMailSender();
|
||||
MimeMessage mimeMessage = mailSender.createMimeMessage();
|
||||
try {
|
||||
MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage,
|
||||
|
|
|
@ -15,34 +15,26 @@ spring:
|
|||
multipart:
|
||||
max-file-size: 128MB
|
||||
max-request-size: 128MB
|
||||
mail:
|
||||
properties.mail.smtp.ssl.enable: ${hoj.mail.ssl}
|
||||
properties.mail.smtp.starttls.enable: true
|
||||
properties.mail.smtp.starttls.required: true
|
||||
username: ${hoj.mail.username}
|
||||
password: ${hoj.mail.password}
|
||||
host: ${hoj.mail.host}
|
||||
port: ${hoj.mail.port}
|
||||
redis:
|
||||
host: ${hoj.redis.host:${hoj-backstage.config.redis.host}}
|
||||
port: ${hoj.redis.port:${hoj-backstage.config.redis.port}}
|
||||
host: ${hoj.redis.host:${REDIS_HOST:172.20.0.2}}
|
||||
port: ${hoj.redis.port:${REDIS_PORT:6379}}
|
||||
timeout: 60000
|
||||
jedis:
|
||||
pool:
|
||||
min-idle: 10 #连接池中的最小空闲连接
|
||||
max-idle: 200 #连接池中的最大空闲连接
|
||||
max-active: 400 #连接池最大连接数(使用负值表示没有限制)
|
||||
max-idle: 50 #连接池中的最大空闲连接
|
||||
max-active: 200 #连接池最大连接数(使用负值表示没有限制)
|
||||
max-wait: -1 #连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||
password: ${hoj.redis.password:${hoj-backstage.config.redis.password}}
|
||||
password: ${hoj.redis.password:${REDIS_PASSWORD:hoj123456}}
|
||||
datasource:
|
||||
username: ${hoj.db.username:${hoj-backstage.config.db.username}}
|
||||
password: ${hoj.db.password:${hoj-backstage.config.db.password}}
|
||||
url: jdbc:mysql://${hoj.db.host:${hoj-backstage.config.db.host}}:${hoj.db.port:${hoj-backstage.config.db.port}}/${hoj.db.name:${hoj-backstage.config.db.name}}?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true
|
||||
username: ${hoj.db.username:${MYSQL_USERNAME:root}}
|
||||
password: ${hoj.db.password:${MYSQL_ROOT_PASSWORD:hoj123456}}
|
||||
url: jdbc:mysql://${hoj.db.host:${MYSQL_HOST:172.20.0.3}}:${hoj.db.port:${MYSQL_PORT:3306}}/${hoj.db.name:${MYSQL_DATABASE_NAME:hoj}}?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
initial-size: 10 # 初始化时建立物理连接的个数。初始化发生在显示调用init方法,或者第一次getConnection时
|
||||
min-idle: 20 # 最小连接池数量
|
||||
maxActive: 400 # 最大连接池数量
|
||||
maxActive: 200 # 最大连接池数量
|
||||
maxWait: 60000 # 获取连接时最大等待时间,单位毫秒。配置了maxWait之后,缺省启用公平锁,并发效率会有所下降,如果需要可以通过配置
|
||||
timeBetweenEvictionRunsMillis: 60000 # 关闭空闲连接的检测时间间隔.Destroy线程会检测连接的间隔时间,如果连接空闲时间大于等于minEvictableIdleTimeMillis则关闭物理连接。
|
||||
minEvictableIdleTimeMillis: 300000 # 连接的最小生存时间.连接保持空闲而不被驱逐的最小时间
|
||||
|
@ -72,8 +64,8 @@ mybatis-plus:
|
|||
shiro-redis:
|
||||
enabled: true
|
||||
redis-manager:
|
||||
host: ${hoj.redis.host:${hoj-backstage.config.redis.host}}:${hoj.redis.port:${hoj-backstage.config.redis.port}}
|
||||
password: ${hoj.redis.password:${hoj-backstage.config.redis.password}}
|
||||
host: ${hoj.redis.host:${REDIS_HOST:172.20.0.2}}:${hoj.redis.port:${REDIS_PORT:6379}}
|
||||
password: ${hoj.redis.password:${REDIS_PASSWORD:hoj123456}}
|
||||
|
||||
ribbon:
|
||||
# 指的是建立连接所用的时间,适用于网络状况正常的情况下,俩端连接所用的时间 单位是秒
|
||||
|
|
|
@ -1,47 +1,6 @@
|
|||
hoj-backstage:
|
||||
port: ${BACKEND_SERVER_PORT:6688} # 本服务器启动的端口号
|
||||
nacos-url: ${NACOS_URL:172.20.0.4:8848} # nacos的地址
|
||||
open-remote-judge: ${OPEN_REMOTE_JUDGE:false} # 是否开启vj
|
||||
config:
|
||||
jwt:
|
||||
# 加密秘钥 默认则生成32位随机密钥
|
||||
secret: ${JWT_TOKEN_SECRET:default}
|
||||
# token默认为24小时 86400s
|
||||
expire: ${JWT_TOKEN_EXPIRE:86400}
|
||||
# token默认12小时可自动刷新
|
||||
checkRefreshExpire: ${JWT_TOKEN_FRESH_EXPIRE:43200}
|
||||
header: token
|
||||
judge:
|
||||
# 调用判题服务器的token 默认则生成32位随机密钥
|
||||
token: ${JUDGE_TOKEN:default}
|
||||
db: # mysql数据库服务配置
|
||||
host: ${MYSQL_HOST:172.20.0.3}
|
||||
public-host: ${MYSQL_PUBLIC_HOST:172.20.0.3}
|
||||
port: ${MYSQL_PORT:3306}
|
||||
name: ${MYSQL_DATABASE_NAME:hoj} # 默认hoj
|
||||
username: ${MYSQL_USERNAME:root}
|
||||
password: ${MYSQL_ROOT_PASSWORD:hoj123456}
|
||||
mail: # 邮箱服务配置
|
||||
ssl: true
|
||||
username: ${EMAIL_USERNMAE:your_email_username}
|
||||
password: ${EMAIL_PASSWORD:your_email_password}
|
||||
host: ${EMAIL_SERVER_HOST:your_email_host}
|
||||
port: ${EMAIL_SERVER_PORT:465}
|
||||
background-img: https://cdn.jsdelivr.net/gh/HimitZH/CDN/images/HCODE.png # 邮箱系统发送邮件模板的背景图片地址
|
||||
redis: # redis服务配置
|
||||
host: ${REDIS_HOST:172.20.0.2}
|
||||
port: ${REDIS_PORT:6379}
|
||||
password: ${REDIS_PASSWORD:hoj123456}
|
||||
hdu:
|
||||
account:
|
||||
username: ${HDU_ACCOUNT_USERNAME_LIST:}
|
||||
password: ${HDU_ACCOUNT_PASSWORD_LIST:}
|
||||
cf:
|
||||
account:
|
||||
username: ${CF_ACCOUNT_USERNAME_LIST:}
|
||||
password: ${CF_ACCOUNT_USERNAME_LIST:}
|
||||
|
||||
|
||||
server:
|
||||
port: ${hoj-backstage.port}
|
||||
spring:
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,65 @@
|
|||
package top.hcode.hoj.config;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @Author: Himit_ZH
|
||||
* @Date: 2021/5/21 17:57
|
||||
* @Description:
|
||||
*/
|
||||
@Configuration
|
||||
@RefreshScope
|
||||
@Data
|
||||
public class DruidConfiguration {
|
||||
|
||||
@Value("${hoj.db.username:root}")
|
||||
private String username;
|
||||
|
||||
@Value("${hoj.db.password:hoj123456}")
|
||||
private String password;
|
||||
|
||||
@Value("${hoj.db.public-host:172.20.0.3}")
|
||||
private String host;
|
||||
|
||||
@Value("${hoj.db.port:3306}")
|
||||
private Integer port;
|
||||
|
||||
@Value("${hoj.db.name:hoj}")
|
||||
private String name;
|
||||
|
||||
@Value("${spring.datasource.driver-class-name}")
|
||||
private String driverClassName;
|
||||
|
||||
@Value("${spring.datasource.initial-size}")
|
||||
private Integer initialSize;
|
||||
|
||||
@Value("${spring.datasource.min-idle}")
|
||||
private Integer minIdle;
|
||||
|
||||
@Value("${spring.datasource.maxActive}")
|
||||
private Integer maxActive;
|
||||
|
||||
@Value("${spring.datasource.maxWait}")
|
||||
private Integer maxWait;
|
||||
|
||||
@Bean(name = "datasource")
|
||||
@RefreshScope
|
||||
public DruidDataSource dataSource() {
|
||||
DruidDataSource datasource = new DruidDataSource();
|
||||
String url = "jdbc:mysql://" + host + ":" + port + "/" + name + "?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true";
|
||||
datasource.setUrl(url);
|
||||
datasource.setUsername(username);
|
||||
datasource.setPassword(password);
|
||||
datasource.setDriverClassName(driverClassName);
|
||||
datasource.setMaxActive(maxActive);
|
||||
datasource.setInitialSize(initialSize);
|
||||
datasource.setMinIdle(minIdle);
|
||||
datasource.setMaxWait(maxWait);
|
||||
return datasource;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue