-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from cyjseagull/feature-milestone2
fix start problems
- Loading branch information
Showing
11 changed files
with
105 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
source ../../wedpr_ddl.sql | ||
source ../../tables_quartz.sql | ||
source ../../wedpr_dml.sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...components/hook/src/main/java/com/webank/wedpr/components/hook/config/UserHookConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2017-2025 [webank-wedpr] | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
* | ||
*/ | ||
|
||
package com.webank.wedpr.components.hook.config; | ||
|
||
import com.webank.wedpr.components.hook.UserHook; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.config.ConfigurableBeanFactory; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Scope; | ||
|
||
@Configuration | ||
public class UserHookConfig { | ||
private static final Logger logger = LoggerFactory.getLogger(UserHookConfig.class); | ||
|
||
@Bean(name = "userHook") | ||
@Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON) | ||
@ConditionalOnMissingBean | ||
public UserHook userHook() { | ||
return new UserHook(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
178 changes: 39 additions & 139 deletions
178
...omponents/mybatis/src/main/java/com/webank/wedpr/components/mybatis/DataSourceConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,139 +1,39 @@ | ||
package com.webank.wedpr.components.mybatis; | ||
|
||
import com.alibaba.druid.pool.DruidDataSource; | ||
import java.util.Map; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class DataSourceConfig { | ||
private static final Logger logger = LoggerFactory.getLogger(DataSourceConfig.class); | ||
|
||
@Value("${spring.datasource.url}") | ||
private String url; | ||
|
||
@Value("${spring.datasource.username}") | ||
private String username; | ||
|
||
@Value("${spring.datasource.password}") | ||
private String password; | ||
|
||
@Value("${spring.datasource.driverClassName}") | ||
private String driverClassName; | ||
|
||
@Value("${spring.datasource.defaultAutoCommit}") | ||
private boolean defaultAutoCommit; | ||
|
||
@Value("${spring.datasource.initialSize}") | ||
private int initialSize; | ||
|
||
@Value("${spring.datasource.maxActive}") | ||
private int maxActive; | ||
|
||
@Value("${spring.datasource.maxIdle}") | ||
private int maxIdle; | ||
|
||
@Value("${spring.datasource.minIdle}") | ||
private int minIdle; | ||
|
||
@Value("${spring.datasource.queryTimeout}") | ||
private int queryTimeout = 0; | ||
|
||
@Value("${spring.datasource.keepAlive}") | ||
private boolean keepAlive; | ||
|
||
@Value("${spring.datasource.testOnBorrow}") | ||
private boolean testOnBorrow; | ||
|
||
@Value("${spring.datasource.testOnReturn}") | ||
private boolean testOnReturn; | ||
|
||
@Value("${spring.datasource.testWhileIdle}") | ||
private boolean testWhileIdle; | ||
|
||
@Value("${spring.datasource.maxWait}") | ||
private long maxWait; | ||
|
||
@Value("${spring.datasource.timeBetweenEvictionRunsMillis}") | ||
private long timeBetweenEvictionRunsMillis; | ||
|
||
@Value("${spring.datasource.minEvictableIdleTimeMillis}") | ||
private long minEvictableIdleTimeMillis; | ||
|
||
@Value("${spring.datasource.validationQuery}") | ||
private String validationQuery; | ||
|
||
@Value("${spring.datasource.validationQueryTimeout}") | ||
private int validationQueryTimeout; | ||
|
||
@Value("${spring.datasource.removeAbandoned}") | ||
private boolean removeAbandoned; | ||
|
||
@Value("${spring.datasource.logAbandoned}") | ||
private boolean logAbandoned; | ||
|
||
@Value("${spring.datasource.removeAbandonedTimeout}") | ||
private int removeAbandonedTimeout; | ||
|
||
@Value("${spring.datasource.poolPreparedStatements}") | ||
private boolean poolPreparedStatements; | ||
|
||
@Value("${spring.datasource.connectionProperties}") | ||
private String connectionProperties; | ||
|
||
@Value("${spring.datasource.filters}") | ||
private String filters; | ||
|
||
@Bean(name = "dataSource", destroyMethod = "close") | ||
public DruidDataSource dataSource() throws Exception { | ||
|
||
logger.info("dataSource dbUrl:{}", url); | ||
logger.info("dataSource dbUsername:{}", username); | ||
logger.info("dataSource driverClassName:{}", driverClassName); | ||
logger.info("dataSource queryTimeout:{}", queryTimeout); | ||
|
||
// https://github.com/alibaba/druid/wiki/DruidDataSource%E9%85%8D%E7%BD%AE | ||
|
||
DruidDataSource datasource = new DruidDataSource(); | ||
datasource.setUrl(url); | ||
datasource.setUsername(username); | ||
datasource.setPassword(password); | ||
datasource.setDriverClassName(driverClassName); | ||
datasource.setDefaultAutoCommit(defaultAutoCommit); | ||
// configuration | ||
datasource.setInitialSize(initialSize); | ||
datasource.setMaxActive(maxActive); | ||
datasource.setMinIdle(maxIdle); | ||
datasource.setMinIdle(minIdle); | ||
datasource.setTestOnBorrow(testOnBorrow); | ||
datasource.setTestOnReturn(testOnReturn); | ||
datasource.setTestWhileIdle(testWhileIdle); | ||
datasource.setValidationQuery(validationQuery); | ||
datasource.setValidationQueryTimeout(validationQueryTimeout); | ||
datasource.setQueryTimeout(queryTimeout); | ||
// | ||
datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); | ||
datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); | ||
// datasource.setMaxEvictableIdleTimeMillis(minEvictableIdleTimeMillis); | ||
datasource.setKeepAlive(keepAlive); | ||
|
||
datasource.setRemoveAbandoned(removeAbandoned); | ||
datasource.setLogAbandoned(logAbandoned); | ||
datasource.setRemoveAbandonedTimeout(removeAbandonedTimeout); | ||
|
||
datasource.setMaxWait(maxWait); | ||
datasource.setPoolPreparedStatements(poolPreparedStatements); | ||
datasource.setConnectionProperties(connectionProperties); | ||
datasource.setFilters(filters); | ||
|
||
datasource.init(); | ||
Map<String, Object> statData = datasource.getStatData(); | ||
|
||
logger.info("create druid datasource successfully: {}", statData); | ||
|
||
return datasource; | ||
} | ||
} | ||
/* | ||
* Copyright 2017-2025 [webank-wedpr] | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
* | ||
*/ | ||
|
||
package com.webank.wedpr.components.mybatis; | ||
|
||
import javax.sql.DataSource; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class DataSourceConfig { | ||
private static final Logger logger = LoggerFactory.getLogger(DataSourceConfig.class); | ||
|
||
@Bean(name = "dataSource", destroyMethod = "close") | ||
@ConditionalOnMissingBean | ||
public DataSource dataSource() throws Exception { | ||
logger.info("Load DataSource"); | ||
if (MybatisConfig.MYBATIS_CONFIG != null) { | ||
DataSource dataSource = DataSourceBuilder.build(MybatisConfig.MYBATIS_CONFIG); | ||
logger.info("Load DataSource from configuration success"); | ||
return dataSource; | ||
} | ||
return DataSourceBuilder.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters