多数据源访问报错

Blade 未结 1 165

一、该问题的重现步骤是什么?

1. 多数据源访问报错

#数据源配置
spring:
  data:
    redis:
      ##redis 单机环境配置
      host: 192.168.5.69
      port: 6379
      password: ENC(Vkw+9XJ8ZRjMxmlG5r0z8U6v5wEtloLRlkNSHiNobf2U)
      database: 0
      ssl:
        enabled: false
      ##redis 集群环境配置
      #cluster:
      #  nodes: 127.0.0.1:7001,127.0.0.1:7002,127.0.0.1:7003
      #  commandTimeout: 5000

  autoconfigure:
    exclude: com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure
  datasource:
    dynamic:
      druid:
        validation-query: select 1
      primary: master
      datasource:
        master:
          driver-class-name: com.mysql.cj.jdbc.Driver
          url: jdbc:mysql://192.168.5.69:3306/blade?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8
          username: ENC(YwgUf5Dn85M006kAndkXpJdzn18vWH1CA7j6xzu7Yh2s)
          password: ENC(6Yi8I3hfyoKcFCMkoSvyjb+)
        slave1:
          driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
          url: jdbc:sqlserver://192.168.5.177:1433;databaseName=imes_mx_kc;
          username: ENC(vni23gLxF1qQbMAYJB8QQQ3FBgXvKcRhXwFqPd9WygQWyvkttf18wBcjsd)
          password: ENC(MJhl1YSzzTi4Rn03ogV/DA2b/9DHqqw16x52WfSSbPxLLh0ltk+)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.material.mapper.WarehouseMapper">


    <select id="selectList" resultType="org.springblade.modules.material.entity.WarehouseEntity">
        SELECT * FROM ( SELECT d.fEntryid number,a.fProductNumber product_number,a.fProductName product_name,
                               a.fModel model,c.MC002 storage_name,a.fStorehouse storage_location,d.fNumber storage_number,
                               a.extend1 unit,d.fPackNum pack_number,d.fManufactor manufacturer,a.fTimeBatch time_batch,
                               a.fErpNumber erp_number,d.extend1 manufacturing_no,d.fCHNumber production_number,
                               d.fTransplantNumber transplant_number,d.extend2 inspection_number,d.extend3 expiration_date,
                               d.extend4 source_number,a.id,a.fIndex,a.extend2,a.extend3,a.extend5 AS flag,a.fNumber AS fAllfNumber,
                               a.fPackingQuantity,a.fconversion,a.fWarehouse,d.extend5
                         FROM t_invla a INNER JOIN t_invla_entry d ON a.id = d.finterid AND d.fNumber!= 0
           INNER JOIN ( SELECT * FROM MXTEST.mingxin.dbo.CMSMC WHERE UDF01 = '是' ) c ON a.fWarehouse = c.MC001) AS d
             WHERE 1 = 1
    </select>

</mapper>
public interface WarehouseMapper extends BaseMapper<WarehouseEntity> {

	List<WarehouseEntity> selectList();
}
@Service
@DS("slave1")
public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper, WarehouseEntity> implements IWarehouseService {
	@Override
	public List<WarehouseEntity> getList() {
		return baseMapper.selectList();
	}
}

@RestController
@AllArgsConstructor
@RequestMapping("/blade-material/warehouse")
public class WarehouseController {

	private IWarehouseService warehouseService;

	/**
	 * 获取库存信息
	 */
	@GetMapping("/getList")
	public List<WarehouseEntity> getList() {
		return warehouseService.getList();
	}
}

 调用controller中的getList接口报错:

2025-01-03 12:56:54.495 ERROR 4332 --- [reate-720060219] com.alibaba.druid.pool.DruidDataSource   : create connection SQLException, url: jdbc:sqlserver://192.168.5.177:1433;databaseName=imes_mx_kc, errorCode 0, state 08S01


com.microsoft.sqlserver.jdbc.SQLServerException: 驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“The server selected protocol version TLS10 is not accepted by client preferences [TLS13, TLS12]”。


三、你正在使用的是什么产品,什么版本?在什么操作系统上?

blade-boot jdk 17,windows


四、请提供详细的错误堆栈信息,这很重要。


2025-01-03 12:56:54.495 ERROR 4332 --- [reate-720060219] com.alibaba.druid.pool.DruidDataSource   : create connection SQLException, url: jdbc:sqlserver://192.168.5.177:1433;databaseName=imes_mx_kc, errorCode 0, state 08S01


com.microsoft.sqlserver.jdbc.SQLServerException: 驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“The server selected protocol version TLS10 is not accepted by client preferences [TLS13, TLS12]”。 ClientConnectionId:00d14668-c711-4949-8890-5eb96ce69f0f

at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:3806)

at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1906)

at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:3329)

at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2950)

at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:2790)

at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1663)

at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1064)

at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:132)

at com.alibaba.druid.filter.stat.StatFilter.connection_connect(StatFilter.java:244)

at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:126)

at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1687)

at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1803)

at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2928)

Caused by: javax.net.ssl.SSLHandshakeException: The server selected protocol version TLS10 is not accepted by client preferences [TLS13, TLS12]

at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131)

at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:117)

at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:365)

at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:321)

at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:312)

at java.base/sun.security.ssl.ServerHello$ServerHelloConsumer.onServerHello(ServerHello.java:981)

at java.base/sun.security.ssl.ServerHello$ServerHelloConsumer.consume(ServerHello.java:903)

at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:396)

at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:480)

at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:458)

at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:201)

at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:172)

at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1506)

at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1421)

at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:455)

at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:426)

at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1795)

... 11 common frames omitted


1条回答
  • 2天前

    pom配置如下:

    com.microsoft.sqlservermssql-jdbc11.2.0.jre17


    回答: 2天前

    搞定了

    0 讨论(0)
提交回复