wiki不能保存问题修复,数据源创建优化
This commit is contained in:
72
.gitignore
vendored
72
.gitignore
vendored
@@ -1,6 +1,70 @@
|
|||||||
# Created by .ignore support plugin (hsz.mobi)
|
|
||||||
.idea
|
|
||||||
*.iml
|
|
||||||
tmlog*.lck
|
tmlog*.lck
|
||||||
tmlog*.log
|
|
||||||
dependency-reduced-pom.xml
|
dependency-reduced-pom.xml
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
# Build Tools
|
||||||
|
|
||||||
|
.gradle
|
||||||
|
/build/
|
||||||
|
!gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
# IDE
|
||||||
|
|
||||||
|
### STS ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
nbproject/private/
|
||||||
|
build/*
|
||||||
|
nbbuild/
|
||||||
|
dist/
|
||||||
|
nbdist/
|
||||||
|
.nb-gradle/
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
# Others
|
||||||
|
*.log
|
||||||
|
*.xml.versionsBackup
|
||||||
|
|
||||||
|
!*/build/*.java
|
||||||
|
!*/build/*.html
|
||||||
|
!*/build/*.xml
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
# rebel
|
||||||
|
rebel.xml
|
||||||
|
|
||||||
|
### gradle构建 ###
|
||||||
|
*.gradle
|
||||||
|
|
||||||
|
### office ###
|
||||||
|
# 忽略office文件打开临时文件 #
|
||||||
|
[~$]*.*
|
||||||
|
tmlog.lck
|
||||||
|
zyplayer-doc-es/src/test/
|
||||||
|
zyplayer-doc-manage/tmlog.lck
|
||||||
|
zyplayer-doc-other/src/
|
||||||
|
zyplayer-doc-other/zyplayer-doc-annotation/src/main/resources/
|
||||||
|
zyplayer-doc-other/zyplayer-doc-annotation/src/test/
|
||||||
|
zyplayer-doc-other/zyplayer-doc-dubbo-libs/dependency-reduced-pom.xml
|
||||||
|
zyplayer-doc-other/zyplayer-doc-dubbo-libs/src/
|
||||||
|
zyplayer-doc-other/zyplayer-doc-test/src/main/java/com/zyplayer/doc/test/db/
|
||||||
|
zyplayer-doc-other/zyplayer-doc-test/src/test/
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class MybatisPlusConfig {
|
|||||||
|
|
||||||
@Bean(name = "manageDatasource")
|
@Bean(name = "manageDatasource")
|
||||||
public DataSource manageDatasource() throws Exception {
|
public DataSource manageDatasource() throws Exception {
|
||||||
return DruidDataSourceUtil.createDataSource(driverClassName, url, username, password);
|
return DruidDataSourceUtil.createDataSource(driverClassName, url, username, password, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "manageSqlSessionFactory")
|
@Bean(name = "manageSqlSessionFactory")
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public class DruidDataSourceUtil {
|
|||||||
|
|
||||||
private static AtomicLong nameId = new AtomicLong(0);
|
private static AtomicLong nameId = new AtomicLong(0);
|
||||||
|
|
||||||
public static DruidDataSource createDataSource(String driverClassName, String url, String username, String password) throws Exception {
|
public static DruidDataSource createDataSource(String driverClassName, String url, String username, String password, boolean breakAfterAcquireFailure) throws Exception {
|
||||||
// 数据源配置
|
// 数据源配置
|
||||||
DruidDataSource dataSource = new DruidDataSource();
|
DruidDataSource dataSource = new DruidDataSource();
|
||||||
dataSource.setDriverClassName(driverClassName);
|
dataSource.setDriverClassName(driverClassName);
|
||||||
@@ -30,7 +30,7 @@ public class DruidDataSourceUtil {
|
|||||||
// 重试3次,失败退出,源码里是errorCount > connectionErrorRetryAttempts,所以写成2就是3次、、、
|
// 重试3次,失败退出,源码里是errorCount > connectionErrorRetryAttempts,所以写成2就是3次、、、
|
||||||
// CreateConnectionThread 源码在这个类里面
|
// CreateConnectionThread 源码在这个类里面
|
||||||
dataSource.setConnectionErrorRetryAttempts(2);
|
dataSource.setConnectionErrorRetryAttempts(2);
|
||||||
dataSource.setBreakAfterAcquireFailure(false);// 连接出错后不退出,等待下个定时周期重试
|
dataSource.setBreakAfterAcquireFailure(breakAfterAcquireFailure);// false:连接出错后不退出,等待下个定时周期重试,true:失败不再重试
|
||||||
dataSource.setTimeBetweenConnectErrorMillis(180000);// 连接出错后重试时间间隔3分钟
|
dataSource.setTimeBetweenConnectErrorMillis(180000);// 连接出错后重试时间间隔3分钟
|
||||||
dataSource.setName("zyplayer-doc-db-" + nameId.incrementAndGet());
|
dataSource.setName("zyplayer-doc-db-" + nameId.incrementAndGet());
|
||||||
if (url.contains("oracle")) {
|
if (url.contains("oracle")) {
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class DbDatasourceController {
|
|||||||
dbDatasource.setSourcePassword(dbDatasourceSel.getSourcePassword());
|
dbDatasource.setSourcePassword(dbDatasourceSel.getSourcePassword());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DatabaseFactoryBean databaseFactoryBean = DatasourceUtil.createDatabaseFactoryBean(dbDatasource);
|
DatabaseFactoryBean databaseFactoryBean = DatasourceUtil.createDatabaseFactoryBean(dbDatasource, true);
|
||||||
if (databaseFactoryBean == null) {
|
if (databaseFactoryBean == null) {
|
||||||
return DocDbResponseJson.warn("获取数据源失败,请检查配置是否正确");
|
return DocDbResponseJson.warn("获取数据源失败,请检查配置是否正确");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,10 @@ import org.mybatis.spring.SqlSessionTemplate;
|
|||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class DatasourceUtil {
|
public class DatasourceUtil {
|
||||||
private static SqlLogInterceptor sqlLogInterceptor = new SqlLogInterceptor();
|
private static SqlLogInterceptor sqlLogInterceptor = new SqlLogInterceptor();
|
||||||
|
|
||||||
public static DatabaseFactoryBean createDatabaseFactoryBean(DbDatasource dbDatasource) throws Exception {
|
public static DatabaseFactoryBean createDatabaseFactoryBean(DbDatasource dbDatasource, boolean breakAfterAcquireFailure) throws Exception {
|
||||||
Resource[] resources = null;
|
Resource[] resources = null;
|
||||||
// 描述连接信息的对象
|
// 描述连接信息的对象
|
||||||
DatabaseFactoryBean databaseFactoryBean = new DatabaseFactoryBean();
|
DatabaseFactoryBean databaseFactoryBean = new DatabaseFactoryBean();
|
||||||
@@ -62,7 +60,7 @@ public class DatasourceUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// 数据源配置
|
// 数据源配置
|
||||||
DruidDataSource dataSource = DruidDataSourceUtil.createDataSource(dbDatasource.getDriverClassName(), dbDatasource.getSourceUrl(), dbDatasource.getSourceName(), dbDatasource.getSourcePassword());
|
DruidDataSource dataSource = DruidDataSourceUtil.createDataSource(dbDatasource.getDriverClassName(), dbDatasource.getSourceUrl(), dbDatasource.getSourceName(), dbDatasource.getSourcePassword(), breakAfterAcquireFailure);
|
||||||
// 创建sqlSessionTemplate
|
// 创建sqlSessionTemplate
|
||||||
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
|
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
|
||||||
sqlSessionFactoryBean.setDataSource(dataSource);
|
sqlSessionFactoryBean.setDataSource(dataSource);
|
||||||
|
|||||||
@@ -104,13 +104,15 @@ public class DatabaseRegistrationBean {
|
|||||||
*/
|
*/
|
||||||
private synchronized DatabaseFactoryBean createFactoryById(Long sourceId) {
|
private synchronized DatabaseFactoryBean createFactoryById(Long sourceId) {
|
||||||
DatabaseFactoryBean factoryBean = databaseFactoryBeanMap.get(sourceId);
|
DatabaseFactoryBean factoryBean = databaseFactoryBeanMap.get(sourceId);
|
||||||
if (factoryBean != null) return factoryBean;
|
if (factoryBean != null) {
|
||||||
|
return factoryBean;
|
||||||
|
}
|
||||||
DbDatasource dbDatasource = dbDatasourceService.getById(sourceId);
|
DbDatasource dbDatasource = dbDatasourceService.getById(sourceId);
|
||||||
if (dbDatasource == null) {
|
if (dbDatasource == null) {
|
||||||
throw new ConfirmException("未找到指定数据源配置信息");
|
throw new ConfirmException("未找到指定数据源配置信息");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
DatabaseFactoryBean databaseFactoryBean = DatasourceUtil.createDatabaseFactoryBean(dbDatasource);
|
DatabaseFactoryBean databaseFactoryBean = DatasourceUtil.createDatabaseFactoryBean(dbDatasource, false);
|
||||||
if (databaseFactoryBean == null) {
|
if (databaseFactoryBean == null) {
|
||||||
throw new ConfirmException("获取数据源失败");
|
throw new ConfirmException("获取数据源失败");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ zyplayer:
|
|||||||
doc-lib-path: D:/zyplayerDoc/dubbo
|
doc-lib-path: D:/zyplayerDoc/dubbo
|
||||||
# 优先使用zookeeper,未配置时找nacos的配置
|
# 优先使用zookeeper,未配置时找nacos的配置
|
||||||
zookeeper:
|
zookeeper:
|
||||||
url: 127.0.0.1:2181
|
# url: 127.0.0.1:2181
|
||||||
# 服务参数那些信息的服务地址,dubbo7.0新特性
|
# 服务参数那些信息的服务地址,dubbo7.0新特性
|
||||||
# metadata-url: 127.0.0.1:2181
|
# metadata-url: 127.0.0.1:2181
|
||||||
nacos:
|
nacos:
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ public class WikiPageController {
|
|||||||
}
|
}
|
||||||
if (wikiPage.getParentId() != null && wikiPage.getParentId() > 0) {
|
if (wikiPage.getParentId() != null && wikiPage.getParentId() > 0) {
|
||||||
WikiPage wikiPageParent = wikiPageService.getById(wikiPage.getParentId());
|
WikiPage wikiPageParent = wikiPageService.getById(wikiPage.getParentId());
|
||||||
if (Objects.equals(wikiPage.getSpaceId(), wikiPageParent.getSpaceId())) {
|
if (!Objects.equals(wikiPage.getSpaceId(), wikiPageParent.getSpaceId())) {
|
||||||
return DocResponseJson.warn("当前空间和父页面的空间不一致,请重新选择父页面!");
|
return DocResponseJson.warn("当前空间和父页面的空间不一致,请重新选择父页面!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user