diff --git a/ruoyi-common/ruoyi-common-alibaba-bom/pom.xml b/ruoyi-common/ruoyi-common-alibaba-bom/pom.xml index 9ec6b088b..3a8ee0526 100644 --- a/ruoyi-common/ruoyi-common-alibaba-bom/pom.xml +++ b/ruoyi-common/ruoyi-common-alibaba-bom/pom.xml @@ -17,7 +17,7 @@ 2.4.0 2023.0.1.2 1.8.8 - 2.3.0 + 2.4.0 2.5.1 3.3.4 3.3.1 diff --git a/ruoyi-common/ruoyi-common-seata/src/main/java/org/dromara/common/seata/config/SeataConfiguration.java b/ruoyi-common/ruoyi-common-seata/src/main/java/org/dromara/common/seata/config/SeataConfiguration.java index 6b4ddb20d..0d065de0c 100644 --- a/ruoyi-common/ruoyi-common-seata/src/main/java/org/dromara/common/seata/config/SeataConfiguration.java +++ b/ruoyi-common/ruoyi-common-seata/src/main/java/org/dromara/common/seata/config/SeataConfiguration.java @@ -1,8 +1,6 @@ package org.dromara.common.seata.config; -import org.dromara.common.core.factory.YmlPropertySourceFactory; import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.context.annotation.PropertySource; /** * seata 配置 @@ -10,7 +8,6 @@ import org.springframework.context.annotation.PropertySource; * @author Lion Li */ @AutoConfiguration -@PropertySource(value = "classpath:common-seata.yml", factory = YmlPropertySourceFactory.class) public class SeataConfiguration { } diff --git a/ruoyi-common/ruoyi-common-seata/src/main/resources/common-seata.yml b/ruoyi-common/ruoyi-common-seata/src/main/resources/common-seata.yml deleted file mode 100644 index 56be998a0..000000000 --- a/ruoyi-common/ruoyi-common-seata/src/main/resources/common-seata.yml +++ /dev/null @@ -1,23 +0,0 @@ -# 内置配置 不允许修改 如需修改请在 nacos 上写相同配置覆盖 -# seata配置 -seata: - config: - type: nacos - nacos: - server-addr: ${spring.cloud.nacos.server-addr} - group: ${spring.cloud.nacos.config.group} - namespace: ${spring.profiles.active} - username: ${spring.cloud.nacos.username} - password: ${spring.cloud.nacos.password} - data-id: seata-server.properties - registry: - type: nacos - nacos: - application: ruoyi-seata-server - server-addr: ${spring.cloud.nacos.server-addr} - group: ${spring.cloud.nacos.discovery.group} - username: ${spring.cloud.nacos.username} - password: ${spring.cloud.nacos.password} - namespace: ${spring.profiles.active} - # 关闭自动代理 - enable-auto-data-source-proxy: false diff --git a/ruoyi-visual/ruoyi-seata-server/pom.xml b/ruoyi-visual/ruoyi-seata-server/pom.xml index 0e569aedc..6491fffa3 100644 --- a/ruoyi-visual/ruoyi-seata-server/pom.xml +++ b/ruoyi-visual/ruoyi-seata-server/pom.xml @@ -27,7 +27,7 @@ jar - 2.3.0 + 2.4.0 2.7.18 5.3.39 2.0 @@ -161,6 +161,12 @@ ${seata.version} + + org.apache.seata + seata-all + ${seata.version} + + org.apache.seata seata-core @@ -199,11 +205,11 @@ ${seata.version} - - org.apache.seata - seata-console - ${seata.version} - + + + + + diff --git a/ruoyi-visual/ruoyi-seata-server/src/main/java/org/apache/seata/core/store/db/AbstractDataSourceProvider.java b/ruoyi-visual/ruoyi-seata-server/src/main/java/org/apache/seata/core/store/db/AbstractDataSourceProvider.java index 4603d2cb6..a1aa3c1da 100644 --- a/ruoyi-visual/ruoyi-seata-server/src/main/java/org/apache/seata/core/store/db/AbstractDataSourceProvider.java +++ b/ruoyi-visual/ruoyi-seata-server/src/main/java/org/apache/seata/core/store/db/AbstractDataSourceProvider.java @@ -16,13 +16,14 @@ */ package org.apache.seata.core.store.db; +import org.apache.seata.common.ConfigurationKeys; +import org.apache.seata.common.exception.ShouldNeverHappenException; import org.apache.seata.common.exception.StoreException; import org.apache.seata.common.executor.Initialize; import org.apache.seata.common.util.ConfigTools; import org.apache.seata.common.util.StringUtils; import org.apache.seata.config.Configuration; import org.apache.seata.config.ConfigurationFactory; -import org.apache.seata.core.constants.ConfigurationKeys; import org.apache.seata.core.constants.DBType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -55,13 +56,13 @@ public abstract class AbstractDataSourceProvider implements DataSourceProvider, */ protected static final Configuration CONFIG = ConfigurationFactory.getInstance(); - private final static String MYSQL_DRIVER_CLASS_NAME = "com.mysql.jdbc.Driver"; + private static final String MYSQL_DRIVER_CLASS_NAME = "com.mysql.jdbc.Driver"; - private final static String MYSQL8_DRIVER_CLASS_NAME = "com.mysql.cj.jdbc.Driver"; + private static final String MYSQL8_DRIVER_CLASS_NAME = "com.mysql.cj.jdbc.Driver"; - private final static String MYSQL_DRIVER_FILE_PREFIX = "mysql-connector-java-"; + private static final String MYSQL_DRIVER_FILE_PREFIX = "mysql-connector-j"; - private final static Map MYSQL_DRIVER_LOADERS; + private static final Map MYSQL_DRIVER_LOADERS; private static final long DEFAULT_DB_MAX_WAIT = 5000; @@ -85,7 +86,7 @@ public abstract class AbstractDataSourceProvider implements DataSourceProvider, } public void validate() { - //valid driver class name + // valid driver class name String driverClassName = getDriverClassName(); // ClassLoader loader = getDriverClassLoader(); // if (null == loader) { @@ -95,15 +96,31 @@ public abstract class AbstractDataSourceProvider implements DataSourceProvider, // loader.loadClass(driverClassName); Class.forName(driverClassName); } catch (ClassNotFoundException exx) { - String driverClassPath = null; String folderPath = System.getProperty("loader.path"); - if (null != folderPath) { - driverClassPath = folderPath + "/jdbc/"; + if (folderPath == null) { + folderPath = System.getProperty("java.class.path"); } + String driverClassPath = Stream.of(folderPath.split(File.pathSeparator)) + .map(File::new) + .filter(File::exists) + .map(file -> file.isFile() ? file.getParentFile() : file) + .filter(Objects::nonNull) + .filter(File::isDirectory) + // Only the MySQL driver needs to be placed in the jdbc folder. + .map(file -> (MYSQL8_DRIVER_CLASS_NAME.equals(driverClassName) + || MYSQL_DRIVER_CLASS_NAME.equals(driverClassName)) + ? new File(file, "jdbc") + : file) + .filter(File::exists) + .filter(File::isDirectory) + .distinct() + .findAny() + .map(File::getAbsolutePath) + .orElseThrow(() -> new ShouldNeverHappenException("cannot find jdbc folder")); throw new StoreException(String.format( - "The driver {%s} cannot be found in the path %s. Please ensure that the appropriate database driver dependencies are included in the classpath.", driverClassName, driverClassPath)); + "The driver {%s} cannot be found in the path %s. Please ensure that the appropriate database driver dependencies are included in the classpath.", + driverClassName, driverClassPath)); } - } /** * generate the datasource @@ -140,17 +157,20 @@ public abstract class AbstractDataSourceProvider implements DataSourceProvider, * @return the db max wait */ protected Long getMaxWait() { - Long maxWait = CONFIG.getLong(ConfigurationKeys.STORE_DB_MAX_WAIT, DEFAULT_DB_MAX_WAIT); - return maxWait; + return CONFIG.getLong(ConfigurationKeys.STORE_DB_MAX_WAIT, DEFAULT_DB_MAX_WAIT); } protected ClassLoader getDriverClassLoader() { - return MYSQL_DRIVER_LOADERS.getOrDefault(getDriverClassName(), ClassLoader.getSystemClassLoader()); + return MYSQL_DRIVER_LOADERS.getOrDefault( + getDriverClassName(), this.getClass().getClassLoader()); } private static Map createMysqlDriverClassLoaders() { Map loaders = new HashMap<>(); - String cp = System.getProperty("java.class.path"); + String cp = System.getProperty("loader.path"); + if (cp == null) { + cp = System.getProperty("java.class.path"); + } if (cp == null || cp.isEmpty()) { return loaders; } @@ -178,7 +198,7 @@ public abstract class AbstractDataSourceProvider implements DataSourceProvider, } try { URL url = file.toURI().toURL(); - ClassLoader loader = new URLClassLoader(new URL[]{url}, ClassLoader.getSystemClassLoader()); + ClassLoader loader = new URLClassLoader(new URL[] {url}, ClassLoader.getSystemClassLoader()); try { loader.loadClass(MYSQL8_DRIVER_CLASS_NAME); loaders.putIfAbsent(MYSQL8_DRIVER_CLASS_NAME, loader); @@ -279,5 +299,4 @@ public abstract class AbstractDataSourceProvider implements DataSourceProvider, protected String getPublicKey() { return CONFIG.getConfig(ConfigurationKeys.STORE_PUBLIC_KEY); } - } diff --git a/ruoyi-visual/ruoyi-seata-server/src/main/resources/application.yml b/ruoyi-visual/ruoyi-seata-server/src/main/resources/application.yml index 663b11d9d..190bf7aa1 100644 --- a/ruoyi-visual/ruoyi-seata-server/src/main/resources/application.yml +++ b/ruoyi-visual/ruoyi-seata-server/src/main/resources/application.yml @@ -19,11 +19,6 @@ logging: # bootstrap-servers: 127.0.0.1:9092 # topic: logback_to_logstash -console: - user: - username: seata - password: seata - seata: config: # support: nacos 、 consul 、 apollo 、 zk 、 etcd3 @@ -52,9 +47,3 @@ seata: ##if use MSE Nacos with auth, mutex with username/password attribute #access-key: "" #secret-key: "" - security: - secretKey: rE7bYayhpvduYwCxuhckybEPDXyna6xwm5m7MZjtjrdXjVxAbXAMccXHyaJvB346 - tokenValidityInMilliseconds: 1800000 - csrf-ignore-urls: /metadata/v1/** - ignore: - urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.jpeg,/**/*.ico,/api/v1/auth/login,/version.json,/health,/error,/vgroup/v1/** diff --git a/ruoyi-visual/ruoyi-seata-server/src/main/resources/lib/seata-server-2.3.0.jar b/ruoyi-visual/ruoyi-seata-server/src/main/resources/lib/seata-server-2.3.0.jar deleted file mode 100644 index 89cff2951..000000000 Binary files a/ruoyi-visual/ruoyi-seata-server/src/main/resources/lib/seata-server-2.3.0.jar and /dev/null differ diff --git a/ruoyi-visual/ruoyi-seata-server/src/main/resources/lib/seata-server-2.4.0.jar b/ruoyi-visual/ruoyi-seata-server/src/main/resources/lib/seata-server-2.4.0.jar new file mode 100644 index 000000000..da7bf12d6 Binary files /dev/null and b/ruoyi-visual/ruoyi-seata-server/src/main/resources/lib/seata-server-2.4.0.jar differ diff --git a/script/config/nacos/application-common.yml b/script/config/nacos/application-common.yml index ac4771d2c..39aa2911d 100644 --- a/script/config/nacos/application-common.yml +++ b/script/config/nacos/application-common.yml @@ -266,6 +266,26 @@ seata: application-id: ${spring.application.name} # Seata 事务组编号,用于 TC 集群名 tx-service-group: ${spring.application.name}-group + config: + type: nacos + nacos: + server-addr: ${spring.cloud.nacos.server-addr} + group: ${spring.cloud.nacos.config.group} + namespace: ${spring.profiles.active} + username: ${spring.cloud.nacos.username} + password: ${spring.cloud.nacos.password} + data-id: seata-server.properties + registry: + type: nacos + nacos: + application: ruoyi-seata-server + server-addr: ${spring.cloud.nacos.server-addr} + group: ${spring.cloud.nacos.discovery.group} + username: ${spring.cloud.nacos.username} + password: ${spring.cloud.nacos.password} + namespace: ${spring.profiles.active} + # 关闭自动代理 + enable-auto-data-source-proxy: false # 多租户配置 tenant: diff --git a/script/docker/skywalking/agent/plugins/apm-seata-skywalking-plugin-2.3.0.jar b/script/docker/skywalking/agent/plugins/apm-seata-skywalking-plugin-2.4.0.jar similarity index 60% rename from script/docker/skywalking/agent/plugins/apm-seata-skywalking-plugin-2.3.0.jar rename to script/docker/skywalking/agent/plugins/apm-seata-skywalking-plugin-2.4.0.jar index 6e52867ea..156cc284a 100644 Binary files a/script/docker/skywalking/agent/plugins/apm-seata-skywalking-plugin-2.3.0.jar and b/script/docker/skywalking/agent/plugins/apm-seata-skywalking-plugin-2.4.0.jar differ