You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/09/26 01:43:16 UTC

[GitHub] [shardingsphere] wangwangwangBoy opened a new issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

wangwangwangBoy opened a new issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703


   ##### As the title, the Spring boot project uses Java for sharding-jdbc configuration, and encountered this error when starting.
   
   ##### Springboot main class:
   
   ```java
   
   import com.netflix.zuul.ZuulFilter;
   import org.springframework.boot.SpringApplication;
   import org.springframework.boot.autoconfigure.SpringBootApplication;
   import org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration;
   import org.springframework.boot.web.servlet.ServletComponentScan;
   import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
   import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
   import org.springframework.cloud.netflix.zuul.filters.discovery.PatternServiceRouteMapper;
   import org.springframework.cloud.openfeign.EnableFeignClients;
   import org.springframework.context.annotation.Bean;
   import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
   
   @EnableZuulProxy
   @SpringBootApplication( scanBasePackageClasses = {GateWayApplication.class,
   		ApplicationContextProvider.class})
   @EnableEurekaClient 
   @ServletComponentScan
   @EnableRedisHttpSession
   public class GateWayApplication {
   	public static void main(String[] args) {
   		SpringApplication.run(GateWayApplication.class, args);
   	}
   
   	@Bean
   	public PatternServiceRouteMapper serviceRouteMapper() {
   		return new PatternServiceRouteMapper("(?<name>^.+)-(?<version>.+$)", "${name}/${version}");
   	}
   
   	
       @Bean
       public ZuulFilter ProvideFilter(){
           return new ProvideFilter();
       }
   	@Bean
   	public RedisService redisService(){
   		return new RedisService();
   	}
   	@Bean
   	public FeignInterceptor feignInterceptor(){
   		return new FeignInterceptor();
   	}
   
   
   }
   
   ```
   
   
   
   ##### My main configuration is as follows:
   
   ```java
   
   import com.alibaba.druid.filter.Filter;
   import com.alibaba.druid.pool.DruidDataSource;
   import com.alibaba.druid.wall.WallConfig;
   import com.alibaba.druid.wall.WallFilter;
   import java.sql.SQLException;
   import java.util.ArrayList;
   import java.util.Collections;
   import java.util.HashMap;
   import java.util.List;
   import java.util.Map;
   import java.util.Properties;
   import javax.sql.DataSource;
   import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
   import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
   import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
   import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
   import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
   import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
   import org.springframework.boot.context.properties.ConfigurationProperties;
   import org.springframework.context.annotation.Bean;
   import org.springframework.context.annotation.Configuration;
   import org.springframework.context.annotation.Primary;
   import org.springframework.jdbc.core.JdbcTemplate;
   import org.springframework.jdbc.datasource.DataSourceTransactionManager;
   
   
   @Configuration
   public class ShardingConfig {
   
   
       private final String DEVICE_LOGICAL_TABLE = "environment_supervise_device_data";
   
       private final String AI_LOGICAL_TABLE = "ai_supervise_device_data";
   
   
       private static final String LARGE_PROJECT_DEPARTMENT = "large_project_department";
   
       private static final String TABLE_RULE = "table_rule";
   
       private static final String DATABASE_RULE = "database_rule";
   
       public static final String DATABASE_SHARDING_ALGORITHM_NAME = "dataBaseShardingAlgorithmNameCreateDate";
       public static final String TABLE_SHARDING_ALGORITHM_NAME = "tableShardingAlgorithmNameCreateDate";
   
      
       private final String TABLE_SHARDING_COLUMN = "create_date";
   
       @Bean
       @Primary
       @ConfigurationProperties(prefix = "spring.datasource")
       public DataSource getDruidDataSource() {
           DruidDataSource druidDataSource = new DruidDataSource();
           List<Filter> filterList = new ArrayList<>();
           filterList.add(wallFilter());
           druidDataSource.setProxyFilters(filterList);
           return druidDataSource;
       }
   
   
       @Bean()
       public DataSource dataSource() throws SQLException {
           Map<String, DataSource> dataSourceMap = new HashMap<>(0);
           dataSourceMap.put(LARGE_PROJECT_DEPARTMENT, createDataSource());
           ShardingTableRuleConfiguration deviceDataRuleConfiguration = getTableRuleConfiguration(DEVICE_LOGICAL_TABLE);
           ShardingTableRuleConfiguration aiDataRuleConfiguration = getTableRuleConfiguration(AI_LOGICAL_TABLE);
   
           Properties properties = new Properties();
           properties.setProperty("sql.show", "true");
   
           ShardingRuleConfiguration shardingRuleConfiguration = new ShardingRuleConfiguration();
           shardingRuleConfiguration.getTables().add(deviceDataRuleConfiguration);
           shardingRuleConfiguration.getTables().add(aiDataRuleConfiguration);
   
           shardingRuleConfiguration.setDefaultDatabaseShardingStrategy(
                   new StandardShardingStrategyConfiguration(TABLE_SHARDING_COLUMN, DATABASE_SHARDING_ALGORITHM_NAME));
           shardingRuleConfiguration.setDefaultTableShardingStrategy(
                   new StandardShardingStrategyConfiguration(TABLE_SHARDING_COLUMN, TABLE_SHARDING_ALGORITHM_NAME));
   
           shardingRuleConfiguration.getShardingAlgorithms()
                   .put(DATABASE_SHARDING_ALGORITHM_NAME,
                           new ShardingSphereAlgorithmConfiguration(DatabaseShardingAlgorithm.DATABASE_SHARDING_ALGORITHM,
                                   properties));
           shardingRuleConfiguration.getShardingAlgorithms()
                   .put(TABLE_SHARDING_ALGORITHM_NAME,
                           new ShardingSphereAlgorithmConfiguration(TableShardingAlgorithm.TABLE_SHARDING_ALGORITHM,
                                   properties));
           shardingRuleConfiguration.getKeyGenerators()
                   .put("snowflake", new ShardingSphereAlgorithmConfiguration("SNOWFLAKE", properties));
   
           
           return ShardingSphereDataSourceFactory
                   .createDataSource(dataSourceMap, Collections.singleton(shardingRuleConfiguration), properties);
   
       }
   
       @Bean
       public DataSourceTransactionManager dataSourceTransactionManager() {
           return new DataSourceTransactionManager(getDruidDataSource());
       }
   
       @Bean
       public JdbcTemplate jdbcTemplate() {
           return new JdbcTemplate(getDruidDataSource());
       }
   
       private DataSource createDataSource() {
           DruidDataSource dataSource = (DruidDataSource) getDruidDataSource();
           return dataSource;
       }
   
       private ShardingTableRuleConfiguration getTableRuleConfiguration(String tableName) {
           KeyGenerateStrategyConfiguration keyGeneratorConfiguration = new KeyGenerateStrategyConfiguration("id",
                   "SNOWFLAKE");
           ShardingTableRuleConfiguration deviceDataRuleConfiguration = new ShardingTableRuleConfiguration(tableName,
                   LARGE_PROJECT_DEPARTMENT + "." + tableName + "_20$->{21..22}0$->{1..9}" + "," +
                           LARGE_PROJECT_DEPARTMENT + "." + tableName + "_20$->{21..22}$->{11..12}");
           deviceDataRuleConfiguration.setDatabaseShardingStrategy(
                   new StandardShardingStrategyConfiguration(TABLE_SHARDING_COLUMN, DATABASE_RULE));
           deviceDataRuleConfiguration.setTableShardingStrategy(
                   new StandardShardingStrategyConfiguration(TABLE_SHARDING_COLUMN, TABLE_RULE));
           deviceDataRuleConfiguration.setKeyGenerateStrategy(keyGeneratorConfiguration);
           return deviceDataRuleConfiguration;
       }
   
       @Bean
       public WallFilter wallFilter() {
           WallFilter wallFilter = new WallFilter();
           wallFilter.setConfig(wallConfig());
           return wallFilter;
       }
   
       @Bean
       public WallConfig wallConfig() {
           WallConfig config = new WallConfig();
           config.setMultiStatementAllow(true);
           config.setNoneBaseStatementAllow(true);
           return config;
       }
   }
   
   ```
   
   ##### The table fragmentation algorithm is configured as follows:
   
   ```java
   
   import com.google.common.collect.Range;
   import java.sql.SQLException;
   import java.util.ArrayList;
   import java.util.Collection;
   import java.util.Date;
   import java.util.List;
   import java.util.Optional;
   import javax.sql.DataSource;
   import org.apache.commons.collections4.CollectionUtils;
   import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
   import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
   import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
   
   
   public class TableShardingAlgorithm implements StandardShardingAlgorithm<Date> {
   
       public static final String TABLE_SHARDING_ALGORITHM = "tableShardingAlgorithm";
   
       private AutoCreateTableConfig autoCreateTableConfig = new AutoCreateTableConfig();
   
       @Override
       public void init() {
   
       }
   
       @Override
       public String getType() {
           return TABLE_SHARDING_ALGORITHM;
       }
   
      
       @Override
       public String doSharding(Collection<String> availableTargetNames, PreciseShardingValue<Date> shardingValue) {
           long value = shardingValue.getValue().getTime();
           if (value <= 0) {
               throw new UnsupportedOperationException("preciseShardingValue is null");
           }
   
           String yearJoinMonthStr = DateUtil.getYearJoinMonthByMillisecond(value);
           Optional<String> optional = availableTargetNames.parallelStream()
                   .filter(item -> item.endsWith(yearJoinMonthStr))
                   .findAny();
           if (optional.isPresent()) {
               judgeTable(optional.get());
               return optional.get();
           }
           throw new UnsupportedOperationException("No available tables according input time:" + yearJoinMonthStr);
       }
   
   
   
       @Override
       public Collection<String> doSharding(Collection<String> availableTargetNames,
               RangeShardingValue<Date> rangeShardingValue) {
           Range<Date> range = rangeShardingValue.getValueRange();
           long startMillisecond = range.lowerEndpoint().getTime();
           long endMillisecond = range.upperEndpoint().getTime();
   
           // 起始年和结束年
           int startYear = Integer.parseInt(DateUtil.getYearByMillisecond(startMillisecond));
           int endYear = Integer.parseInt(DateUtil.getYearByMillisecond(endMillisecond));
           // 起始月和结束月
           int startMonth = Integer.parseInt(DateUtil.getMonthByMillisecond(startMillisecond));
           int endMonth = Integer.parseInt(DateUtil.getMonthByMillisecond(endMillisecond));
   
           int startYearJoinMonth = Integer.parseInt(DateUtil.getYearJoinMonthByMillisecond(startMillisecond));
           int endYearJoinMonth = Integer.parseInt(DateUtil.getYearJoinMonthByMillisecond(endMillisecond));
           List<String> result = startYear == endYear ? theSameYear(startYear, startMonth, endMonth, availableTargetNames)
                   : differentYear(startYear, endYear, startMonth, endMonth, startYearJoinMonth, endYearJoinMonth,
                           availableTargetNames);
           return result;
       }
   
   
       private List<String> theSameYear(int startYear, int startMonth, int endMonth, Collection<String> availableTargetNames) {
           return startMonth == endMonth ? theSameMonth(startYear, startMonth, availableTargetNames)
                   : differentMonth(startYear, startMonth, endMonth, availableTargetNames);
       }
   
   
       private List<String> theSameMonth(int startYear,int startMonth, Collection<String> availableTargetNames) {
           List<String> result = new ArrayList<>();
           String startMonthStr = String.valueOf(startMonth);
           if (startMonthStr.length() == 1) {
               startMonthStr = "0" + startMonthStr;
           }
           String condition = startYear + startMonthStr;
           for (String availableTargetName : availableTargetNames) {
               if (availableTargetName.endsWith(condition)) {
                   result.add(availableTargetName);
               }
           }
           return result;
       }
   
     
       private List<String> differentMonth(int startYear,int startMonth, int endMonth, Collection<String> availableTargetNames) {
           List<String> result = new ArrayList<>();
           for (String availableTargetName : availableTargetNames) {
               for (int i = startMonth; i <= endMonth; i++) {
                   String monthStr = String.valueOf(i);
                   if (monthStr.length() == 1) {
                       monthStr = "0" + monthStr;
                   }
                   if (availableTargetName.endsWith(startYear + monthStr)) {
                       result.add(availableTargetName);
                   }
               }
           }
           return result;
       }
   
       private List<String> differentYear(int startYear, int endYear, int startMonth, int endMonth,
               int startYearJoinMonth, int endYearJoinMonth, Collection<String> availableTargetNames) {
   
           return endYear - startYear == 1 ? twoYears(startYear, endYear, startMonth, endMonth, startYearJoinMonth,
                   endYearJoinMonth, availableTargetNames)
                   : moreThanTwoYears(startYear, endYear, startMonth, endMonth, availableTargetNames);
       }
   
   
    
       private List<String> twoYears(int startYear, int endYear, int startMonth, int endMonth,
               int startYearJoinMonth, int endYearJoinMonth, Collection<String> availableTargetNames
       ) {
           List<String> result = new ArrayList<>();
           int endCondition;
           endCondition = Integer.parseInt(startYear + "12");
           for (int i = startYearJoinMonth; i <= endCondition; i++) {
               for (String availableTargetName : availableTargetNames) {
                   if (availableTargetName.endsWith(String.valueOf(i))) {
                       result.add(availableTargetName);
                   }
               }
           }
   
           endCondition = Integer.parseInt(endYear + "01");
           for (int i = endYearJoinMonth; i >= endCondition; i--) {
               for (String availableTargetName : availableTargetNames) {
                   if (availableTargetName.endsWith(String.valueOf(i))) {
                       result.add(availableTargetName);
                   }
               }
           }
           return result;
       }
   
       private List<String> moreThanTwoYears(int startYear, int endYear, int startMonth, int endMonth,
               Collection<String> availableTargetNames) {
           throw new UnsupportedOperationException("Unsupported more than two years.");
       }
   
   
   }
   
   ```
   
   ##### The database fragmentation algorithm is configured as follows:
   
   ```java
   import com.google.common.collect.Range;
   import java.util.ArrayList;
   import java.util.Collection;
   import java.util.Date;
   import java.util.List;
   import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
   import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
   import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
   
   
   public class DatabaseShardingAlgorithm implements StandardShardingAlgorithm<Date> {
   
       public static final String DATABASE_SHARDING_ALGORITHM = "databaseShardingAlgorithm";
   
      
       @Override
       public String doSharding(Collection<String> availableTargetNames, PreciseShardingValue<Date> shardingValue) {
           Long value = shardingValue.getValue().getTime();
           if (value <= 0) {
               throw new UnsupportedOperationException("preciseShardingValue is null");
           }
           for (String availableTargetName : availableTargetNames) {
               return availableTargetName;
           }
           return null;
       }
   
       @Override
       public Collection<String> doSharding(Collection<String> availableTargetNames, RangeShardingValue<Date> rangeShardingValue) {
   
           List<String> result = new ArrayList<>();
           Range<Date> range = rangeShardingValue.getValueRange();
           long startMillisecond = range.lowerEndpoint().getTime();
           // 起始年和结束年
           int startYear = Integer.parseInt(DateUtil.getYearByMillisecond(startMillisecond));
           return theSameYear(String.valueOf(startYear), availableTargetNames, result);
       }
   
       // 同一年,说明只需要一个库
       private Collection<String> theSameYear(String startTime, Collection<String> availableTargetNames, List<String> result) {
   
           for (String availableTargetName : availableTargetNames) {
               result.add(availableTargetName);
               break;
           }
           return result;
       }
   
   
       private Collection<String> differentYear(int startYear, int endYear, Collection<String> availableTargetNames, List<String> result) {
           for (String availableTargetName : availableTargetNames) {
               for (int i = startYear; i <= endYear; i++) {
                   if (availableTargetName.endsWith(String.valueOf(i))) result.add(availableTargetName);
               }
           }
           return result;
       }
   
       @Override
       public void init() {
   
       }
   
       @Override
       public String getType() {
           return DATABASE_SHARDING_ALGORITHM;
       }
   }
   
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927218199


   @RaigorJiang 
   It still doesn't work
   ![image](https://user-images.githubusercontent.com/46279672/134791481-14738824-29db-4b69-bb17-3dfe069f5892.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927271874


   You are welcome. If the problem has been solved, please close this issue. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-926761830


   Hi @wangwangwangBoy 
   Didn’t see your SPI configuration, the `META-INFO` needs to be configured, please refer to [example](
   https://github.com/apache/shardingsphere/blob/master/examples/shardingsphere-jdbc-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927265494


   @wangwangwangBoy 
   Let me talk about raw java first, I verified the problem:
   1. Your bean `DruidDataSource` is declared as @Primary, so Mybatis will not get the beans created by shardingsphere when using DataSource.
   2. You can create SqlSessionFactoryBean by yourself and specify the bean constructed using shardingsphere, so that your goal can be achieved.
   
   sample code :
   ```java
   @Bean("sharding")
       public DataSource dataSource() throws SQLException {
           Map<String, DataSource> dataSourceMap = new HashMap<>(0);
           dataSourceMap.put("my_test_db", createDataSource());
          ......
   ```
   
   ```java
   @Bean
       public SqlSessionFactoryBean mysqlSessionFactory(@Qualifier("sharding") DataSource dataSource) throws Exception {
           SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
           sqlSessionFactoryBean.setDataSource(dataSource);
           PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
           sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:mapper/*.xml"));
           return sqlSessionFactoryBean;
       }
   ```
   
   My test log shows that the custom algorithm has been used:
   ```
   ### Cause: java.lang.UnsupportedOperationException: No available tables according input time:202007] with root cause
   
   java.lang.UnsupportedOperationException: No available tables according input time:202007
   	at com.mine.shardingjdbc.myconfig.TableShardingAlgorithm.doSharding(TableShardingAlgorithm.java:51) ~[classes/:na]
   	at org.apache.shardingsphere.sharding.route.strategy.type.standard.StandardShardingStrategy.doSharding(StandardShardingStrategy.java:68) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   	at org.apache.shardingsphere.sharding.route.strategy.type.standard.StandardShardingStrategy.doSharding(StandardShardingStrategy.java:57) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeTables(ShardingStandardRoutingEngine.java:214) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.route0(ShardingStandardRoutingEngine.java:194) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeByShardingConditionsWithCondition(ShardingStandardRoutingEngine.java:114) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeByShardingConditions(ShardingStandardRoutingEngine.java:107) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.getDataNodes(ShardingStandardRoutingEngine.java:84) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.route(ShardingStandardRoutingEngine.java:69) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:61) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:47) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   	at org.apache.shardingsphere.infra.route.engine.impl.PartialSQLRouteExecutor.route(PartialSQLRouteExecutor.java:62) ~[shardingsphere-infra-route-5.0.0-beta.jar:5.0.0-beta]
   	at org.apache.shardingsphere.infra.route.engine.SQLRouteEngine.route(SQLRouteEngine.java:52) ~[shardingsphere-infra-route-5.0.0-beta.jar:5.0.0-beta]
   	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.route(KernelProcessor.java:54) ~[shardingsphere-infra-context-5.0.0-beta.jar:5.0.0-beta]
   	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:46) ~[shardingsphere-infra-context-5.0.0-beta.jar:5.0.0-beta]
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.createExecutionContext(ShardingSpherePreparedStatement.java:363) ~[shardingsphere-jdbc-core-5.0.0-beta.jar:5.0.0-beta]
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.execute(ShardingSpherePreparedStatement.java:271) ~[shardingsphere-jdbc-core-5.0.0-beta.jar:5.0.0-beta]
   	at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:46) ~[mybatis-3.4.6.jar:3.4.6]
   	at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74) ~[mybatis-3.4.6.jar:3.4.6]
   	at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50) ~[mybatis-3.4.6.jar:3.4.6]
   	at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) ~[mybatis-3.4.6.jar:3.4.6]
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927274967


   > You are welcome. If the problem has been solved, please close this issue.
   
   Can i upload this demo to template?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927223156


   > @RaigorJiang I compared it with template. Still no problem is found, the attachment is my project, can you help me see it? thanks
   
   I will check it later.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy edited a comment on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy edited a comment on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927211854


   @RaigorJiang @strongduanmu Thanks,The springboot program can run normally, but there is another problem. When inserting into the sub-table, the sub-table operation is not performed, and the doSharding method is not entered.
   ![image](https://user-images.githubusercontent.com/46279672/134790428-873d7983-d0dd-4576-9cbf-c3602158e040.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy edited a comment on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy edited a comment on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927218199


   @RaigorJiang 
   It still doesn't work
   ![image](https://user-images.githubusercontent.com/46279672/134791481-14738824-29db-4b69-bb17-3dfe069f5892.png)
   
   Maybe it?
   ![image](https://user-images.githubusercontent.com/46279672/134791602-364646e4-f0ab-4b0e-b905-b0a52aec361f.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927279671


   > > Can i upload this demo to template?
   > 
   > The files uploaded to the apache repo need to have a license, I am afraid it is not suitable.
   > The community is preparing another forum and we invite you to upload a demo at that time, thank you.
   
   ok,thank you 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927217442


   @wangwangwangBoy 
   FAQ:
   https://shardingsphere.apache.org/document/current/en/others/faq/#1-jdbc-why-there-may-be-an-error-when-configure-both-shardingsphere-jdbc-spring-boot-starter-and-a-spring-boot-starter-of-certain-datasource-poolsuch-as-druid


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927218972


   There are examples of springboot access:
   https://github.com/apache/shardingsphere/tree/master/examples/shardingsphere-jdbc-example/sharding-example
   please check to see if your configuration is incorrect.
   If you still cannot solve it, please upload a demo project to github so that we can help you analyze the problem.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927222260


   [sharding-jdbc.zip](https://github.com/apache/shardingsphere/files/7230658/sharding-jdbc.zip)
   I compared it with template. Still no problem is found, the attachment is my project, can you help me see it? thanks


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy closed issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy closed issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-926703017


   I look forward to hearing from everyone


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927270619


   > The underscore problem, due to the different rules of springboot `1.x` and `2.x`, you can try `-` instead of `_`.
   
   Thank you ,Our database uses `_`, which is why I have to use java configuration.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927277560


   > Can i upload this demo to template?
   
   The files uploaded to the apache repo need to have a license, I am afraid it is not suitable.
   The community is preparing another forum and we invite you to upload a demo at that time, thank you.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927270296


   > @wangwangwangBoy
   > Let me talk about raw java first, I verified the problem:
   > 
   > 1. Your bean `DruidDataSource` is declared as @primary, so Mybatis will not get the beans created by shardingsphere when using DataSource.
   > 2. You can create SqlSessionFactoryBean by yourself and specify the bean constructed using shardingsphere, so that your goal can be achieved.
   > 
   > sample code :
   > 
   > ```java
   > @Bean("sharding")
   >     public DataSource dataSource() throws SQLException {
   >         Map<String, DataSource> dataSourceMap = new HashMap<>(0);
   >         dataSourceMap.put("my_test_db", createDataSource());
   >        ......
   > ```
   > 
   > ```java
   > @Bean
   >     public SqlSessionFactoryBean mysqlSessionFactory(@Qualifier("sharding") DataSource dataSource) throws Exception {
   >         SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
   >         sqlSessionFactoryBean.setDataSource(dataSource);
   >         PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
   >         sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:mapper/*.xml"));
   >         return sqlSessionFactoryBean;
   >     }
   > ```
   > 
   > My test log shows that the custom algorithm has been used:
   > 
   > ```
   > ### Cause: java.lang.UnsupportedOperationException: No available tables according input time:202007] with root cause
   > 
   > java.lang.UnsupportedOperationException: No available tables according input time:202007
   > 	at com.mine.shardingjdbc.myconfig.TableShardingAlgorithm.doSharding(TableShardingAlgorithm.java:51) ~[classes/:na]
   > 	at org.apache.shardingsphere.sharding.route.strategy.type.standard.StandardShardingStrategy.doSharding(StandardShardingStrategy.java:68) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   > 	at org.apache.shardingsphere.sharding.route.strategy.type.standard.StandardShardingStrategy.doSharding(StandardShardingStrategy.java:57) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   > 	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeTables(ShardingStandardRoutingEngine.java:214) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   > 	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.route0(ShardingStandardRoutingEngine.java:194) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   > 	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeByShardingConditionsWithCondition(ShardingStandardRoutingEngine.java:114) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   > 	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeByShardingConditions(ShardingStandardRoutingEngine.java:107) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   > 	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.getDataNodes(ShardingStandardRoutingEngine.java:84) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   > 	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.route(ShardingStandardRoutingEngine.java:69) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   > 	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:61) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   > 	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:47) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   > 	at org.apache.shardingsphere.infra.route.engine.impl.PartialSQLRouteExecutor.route(PartialSQLRouteExecutor.java:62) ~[shardingsphere-infra-route-5.0.0-beta.jar:5.0.0-beta]
   > 	at org.apache.shardingsphere.infra.route.engine.SQLRouteEngine.route(SQLRouteEngine.java:52) ~[shardingsphere-infra-route-5.0.0-beta.jar:5.0.0-beta]
   > 	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.route(KernelProcessor.java:54) ~[shardingsphere-infra-context-5.0.0-beta.jar:5.0.0-beta]
   > 	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:46) ~[shardingsphere-infra-context-5.0.0-beta.jar:5.0.0-beta]
   > 	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.createExecutionContext(ShardingSpherePreparedStatement.java:363) ~[shardingsphere-jdbc-core-5.0.0-beta.jar:5.0.0-beta]
   > 	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.execute(ShardingSpherePreparedStatement.java:271) ~[shardingsphere-jdbc-core-5.0.0-beta.jar:5.0.0-beta]
   > 	at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:46) ~[mybatis-3.4.6.jar:3.4.6]
   > 	at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74) ~[mybatis-3.4.6.jar:3.4.6]
   > 	at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50) ~[mybatis-3.4.6.jar:3.4.6]
   > 	at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) ~[mybatis-3.4.6.jar:3.4.6]
   > ```
   
   It is really the case. After I inject SQLSessionFactory into it, it can work. Your team is really too strong. Thank you very very much!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927250942


   > @wangwangwangBoy
   > I found your datasource configuration is incorrect.
   > `spring.shardingsphere.datasource` is needed.
   > Please refer to [document](https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/configuration/spring-boot-starter/) and [example](https://github.com/apache/shardingsphere/blob/master/examples/shardingsphere-jdbc-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-tables.properties).
   
   My data source configuration does not come from yml. It is in my com.mine.shardingjdbc.myconfig.MyShardingConfig, can you check it again? According to the template, there is no need to configure the data source, the data source created directly in Java
   ![image](https://user-images.githubusercontent.com/46279672/134798346-75b4861c-e0e1-4b4a-8f91-c2a11f82797e.png)
   If you use the debug mode, you will find that the Autowired data source is successful
   ![image](https://user-images.githubusercontent.com/46279672/134798418-5fb2448b-614d-4816-841e-41fbde81e233.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927252721


   > But the project you provided to me is not like that.
   > ![image](https://user-images.githubusercontent.com/5668787/134798668-ae8df182-4c6b-45e0-b997-211fde0e90e4.png)
   
   application-sharing.yml is not used, application.yml is only configured with some spring properties and data source information. The real data source is in MyShardingConfig, you can debug it and find datasource was created by Sharding.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927214881


   @wangwangwangBoy 
   Is there any error log?   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927271274


   OK, please enjoy it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927267011


   The underscore problem, due to the different rules of springboot `1.x` and `2.x`, you can try  `-` instead of `_`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy edited a comment on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy edited a comment on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927252721


   > But the project you provided to me is not like that.
   > ![image](https://user-images.githubusercontent.com/5668787/134798668-ae8df182-4c6b-45e0-b997-211fde0e90e4.png)
   
   application-sharing.yml is not used, application.yml is only configured with some spring properties and data source information. The real data source is in MyShardingConfig, you can debug it and find datasource was created by Sharding.
   
   ![image](https://user-images.githubusercontent.com/46279672/134798837-ef6623e7-71d4-4bd4-8687-b26eb4689251.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927216542


   @RaigorJiang There is no other error message, the startup is normal, and the getType method in the sharding strategy is also accessed, but it looks like the data source of druid is used, and sharding is not used.
   ![image](https://user-images.githubusercontent.com/46279672/134791118-27716c2f-1854-4810-813f-8af7928fd027.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927215110


   Why do you need to import exampleExecuteTemplate? 
   It is recommended that you understand the example project first, and then develop your own business.
   https://github.com/apache/shardingsphere/tree/master/examples


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927271306


   > > @wangwangwangBoy
   > > Let me talk about raw java first, I verified the problem:
   > > 
   > > 1. Your bean `DruidDataSource` is declared as @primary, so Mybatis will not get the beans created by shardingsphere when using DataSource.
   > > 2. You can create SqlSessionFactoryBean by yourself and specify the bean constructed using shardingsphere, so that your goal can be achieved.
   > > 
   > > sample code :
   > > ```java
   > > @Bean("sharding")
   > >     public DataSource dataSource() throws SQLException {
   > >         Map<String, DataSource> dataSourceMap = new HashMap<>(0);
   > >         dataSourceMap.put("my_test_db", createDataSource());
   > >        ......
   > > ```
   > > 
   > > 
   > >     
   > >       
   > >     
   > > 
   > >       
   > >     
   > > 
   > >     
   > >   
   > > ```java
   > > @Bean
   > >     public SqlSessionFactoryBean mysqlSessionFactory(@Qualifier("sharding") DataSource dataSource) throws Exception {
   > >         SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
   > >         sqlSessionFactoryBean.setDataSource(dataSource);
   > >         PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
   > >         sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:mapper/*.xml"));
   > >         return sqlSessionFactoryBean;
   > >     }
   > > ```
   > > 
   > > 
   > >     
   > >       
   > >     
   > > 
   > >       
   > >     
   > > 
   > >     
   > >   
   > > My test log shows that the custom algorithm has been used:
   > > ```
   > > ### Cause: java.lang.UnsupportedOperationException: No available tables according input time:202007] with root cause
   > > 
   > > java.lang.UnsupportedOperationException: No available tables according input time:202007
   > > 	at com.mine.shardingjdbc.myconfig.TableShardingAlgorithm.doSharding(TableShardingAlgorithm.java:51) ~[classes/:na]
   > > 	at org.apache.shardingsphere.sharding.route.strategy.type.standard.StandardShardingStrategy.doSharding(StandardShardingStrategy.java:68) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   > > 	at org.apache.shardingsphere.sharding.route.strategy.type.standard.StandardShardingStrategy.doSharding(StandardShardingStrategy.java:57) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   > > 	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeTables(ShardingStandardRoutingEngine.java:214) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   > > 	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.route0(ShardingStandardRoutingEngine.java:194) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   > > 	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeByShardingConditionsWithCondition(ShardingStandardRoutingEngine.java:114) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   > > 	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeByShardingConditions(ShardingStandardRoutingEngine.java:107) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   > > 	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.getDataNodes(ShardingStandardRoutingEngine.java:84) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   > > 	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.route(ShardingStandardRoutingEngine.java:69) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   > > 	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:61) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   > > 	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:47) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
   > > 	at org.apache.shardingsphere.infra.route.engine.impl.PartialSQLRouteExecutor.route(PartialSQLRouteExecutor.java:62) ~[shardingsphere-infra-route-5.0.0-beta.jar:5.0.0-beta]
   > > 	at org.apache.shardingsphere.infra.route.engine.SQLRouteEngine.route(SQLRouteEngine.java:52) ~[shardingsphere-infra-route-5.0.0-beta.jar:5.0.0-beta]
   > > 	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.route(KernelProcessor.java:54) ~[shardingsphere-infra-context-5.0.0-beta.jar:5.0.0-beta]
   > > 	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:46) ~[shardingsphere-infra-context-5.0.0-beta.jar:5.0.0-beta]
   > > 	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.createExecutionContext(ShardingSpherePreparedStatement.java:363) ~[shardingsphere-jdbc-core-5.0.0-beta.jar:5.0.0-beta]
   > > 	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.execute(ShardingSpherePreparedStatement.java:271) ~[shardingsphere-jdbc-core-5.0.0-beta.jar:5.0.0-beta]
   > > 	at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:46) ~[mybatis-3.4.6.jar:3.4.6]
   > > 	at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74) ~[mybatis-3.4.6.jar:3.4.6]
   > > 	at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50) ~[mybatis-3.4.6.jar:3.4.6]
   > > 	at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) ~[mybatis-3.4.6.jar:3.4.6]
   > > ```
   > 
   > It is really the case. After I inject SQLSessionFactory into it, it can work. Your team is really too strong. Thank you very very much!
   
   Earlier I used Sharding-JDBC 4.0, but it was not very friendly to sub-queries and often reported errors. I listened to my friends’ suggestions to upgrade to 5.x, but found its configuration is different from 4.x, and then out So many questions, thank you very, very much.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927219253


   @RaigorJiang Thank you, I will try it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927240347


   @wangwangwangBoy 
   I found your datasource configuration is incorrect.
   `spring.shardingsphere.datasource` is needed. 
   Please refer to [document](https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/configuration/spring-boot-starter/) and [example](https://github.com/apache/shardingsphere/blob/master/examples/shardingsphere-jdbc-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-tables.properties).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy closed issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy closed issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy edited a comment on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy edited a comment on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927211854


   @RaigorJiang @strongduanmu Thanks,The springboot program can run normally, but there is another problem. When inserting into the sub-table, the sub-table operation is not performed, and the doSharding method is not entered.
   ![image](https://user-images.githubusercontent.com/46279672/134790428-873d7983-d0dd-4576-9cbf-c3602158e040.png)
   
   
   The springboot program start in the template adds this ExampleExecuteTemplate.run(applicationContext.getBean(ExampleService.class)), do I need it too?
   ![image](https://user-images.githubusercontent.com/46279672/134790642-7bd30b1d-583b-47bc-abf3-63213ac57b11.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927224923


   > > @RaigorJiang I compared it with template. Still no problem is found, the attachment is my project, can you help me see it? thanks
   > 
   > I will check it later.
   
   thank you ,here is my  table building statement :
   CREATE TABLE `environment_supervise_device_data` (
   	`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
   	`value` VARCHAR(255) NULL DEFAULT NULL COMMENT '可以是值也可以是json串' COLLATE 'utf8_general_ci',
   	`unit` VARCHAR(255) NULL DEFAULT NULL COMMENT '单位' COLLATE 'utf8_general_ci',
   	`env_attribute_type` VARCHAR(255) NULL DEFAULT NULL COMMENT '环境监测类型' COLLATE 'utf8_general_ci',
   	`create_date` DATETIME NOT NULL,
   	`project_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL,
   	`tenant_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL,
   	`device_id` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
   	`environment_supervise_alarm_data_id` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
   	`wind_direction` VARCHAR(20) NULL DEFAULT NULL COMMENT '风向' COLLATE 'utf8_general_ci',
   	PRIMARY KEY (`id`) USING BTREE,
   	INDEX `idx_project_id` (`project_id`) USING BTREE,
   	INDEX `idx_env_attribute_type` (`env_attribute_type`) USING BTREE,
   	INDEX `idx_tenant_id` (`tenant_id`) USING BTREE,
   	INDEX `idx_environment_device_create_date` (`create_date`) USING BTREE,
   	INDEX `index_environment_supervise_alarm_data_id` (`environment_supervise_alarm_data_id`) USING BTREE
   )
   COLLATE='utf8_general_ci'
   ENGINE=InnoDB;
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927016768


   @RaigorJiang Thank you, there is no configuration before, I will try 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy edited a comment on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy edited a comment on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927222260


   [sharding-jdbc.zip](https://github.com/apache/shardingsphere/files/7230658/sharding-jdbc.zip)
   @RaigorJiang I compared it with template. Still no problem is found, the attachment is my project, can you help me see it? thanks


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927211854


   @RaigorJiang @strongduanmu The springboot program can run normally, but there is another problem. When inserting into the sub-table, the sub-table operation is not performed, and the doSharding method is not entered.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy edited a comment on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy edited a comment on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927250942


   > @wangwangwangBoy
   > I found your datasource configuration is incorrect.
   > `spring.shardingsphere.datasource` is needed.
   > Please refer to [document](https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/configuration/spring-boot-starter/) and [example](https://github.com/apache/shardingsphere/blob/master/examples/shardingsphere-jdbc-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-tables.properties).
   @RaigorJiang
   My data source configuration does not come from yml. It is in my com.mine.shardingjdbc.myconfig.MyShardingConfig, can you check it again? According to the template, there is no need to configure the data source, the data source created directly in Java
   ![image](https://user-images.githubusercontent.com/46279672/134798346-75b4861c-e0e1-4b4a-8f91-c2a11f82797e.png)
   If you use the debug mode, you will find that the Autowired data source is successful
   ![image](https://user-images.githubusercontent.com/46279672/134798418-5fb2448b-614d-4816-841e-41fbde81e233.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927252115


   But the project you provided to me is not like that.
   ![image](https://user-images.githubusercontent.com/5668787/134798668-ae8df182-4c6b-45e0-b997-211fde0e90e4.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wangwangwangBoy commented on issue #12703: [5.0.0-beta] No implementation class load from SPI `org.apache.shardingsphere.sharding.spi.ShardingAlgorithm`

Posted by GitBox <gi...@apache.org>.
wangwangwangBoy commented on issue #12703:
URL: https://github.com/apache/shardingsphere/issues/12703#issuecomment-927260778


   I have used the yml method to inject, but it does not support the underscore in the key.
   ![image](https://user-images.githubusercontent.com/46279672/134800406-09262a05-0d98-44a4-adbe-c03c5db29132.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org