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/02/08 03:00:21 UTC
[GitHub] [shardingsphere] maxh4 opened a new issue #9381: sharding-jdbc-spring-boot-starter auto-configuration class better to rename
maxh4 opened a new issue #9381:
URL: https://github.com/apache/shardingsphere/issues/9381
Hi,
I am using sharding-jdbc-spring-boot-starter as a common sub-module in my project so that I can use some common customized classes in other sub-modules.
After writing unit tests, spring throws an error as following:
`Failed to instantiate [javax.sql.DataSource]: Factory method 'shardingDataSource' threw exception; nested exception is java.lang.IllegalArgumentException: Data sources cannot be empty.`
However, I have added ignore "DataSourceAutoConfiguration.class" annotations in spring-boot start class. This confused me for a while.
`@SpringBootApplication(exclude = {
DruidDataSourceAutoConfigure.class,
DataSourceAutoConfiguration.class,
RabbitAutoConfiguration.class
}`
After looking into the source code here [SpringBootConfiguration.java](https://github.com/apache/shardingsphere/blob/master/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/SpringBootConfiguration.java)
I have updated as below, then my tests got passed.
`@SpringBootApplication(exclude = {
DruidDataSourceAutoConfigure.class,
DataSourceAutoConfiguration.class,
SpringBootConfiguration.class, // ShardingSphereDataSourceAutoConfiguration
RabbitAutoConfiguration.class
}`
So I suggest renaming the class name from "SpringBootConfiguration" to "ShardingSphereDataSourceAutoConfiguration" or other similar to avoid confusion.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] yu199195 commented on issue #9381: sharding-jdbc-spring-boot-starter auto-configuration class better to rename
Posted by GitBox <gi...@apache.org>.
yu199195 commented on issue #9381:
URL: https://github.com/apache/shardingsphere/issues/9381#issuecomment-785684681
I think, ShardingSphereDataSourceAutoConfiguration is comply with Spring-Boot specification
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] menghaoranss closed issue #9381: sharding-jdbc-spring-boot-starter auto-configuration class better to rename
Posted by GitBox <gi...@apache.org>.
menghaoranss closed issue #9381:
URL: https://github.com/apache/shardingsphere/issues/9381
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] tristaZero commented on issue #9381: sharding-jdbc-spring-boot-starter auto-configuration class better to rename
Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #9381:
URL: https://github.com/apache/shardingsphere/issues/9381#issuecomment-774843584
Hi @maxh4 ,
Do you mean `SpringBootConfiguration` of ShardingSphere has conflicts with Spring framework or others?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] yu199195 edited a comment on issue #9381: sharding-jdbc-spring-boot-starter auto-configuration class better to rename
Posted by GitBox <gi...@apache.org>.
yu199195 edited a comment on issue #9381:
URL: https://github.com/apache/shardingsphere/issues/9381#issuecomment-785684681
I think, ShardingSphereAutoConfiguration is comply with Spring-Boot specification @terrymanu What do you think?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] yu199195 commented on issue #9381: sharding-jdbc-spring-boot-starter auto-configuration class better to rename
Posted by GitBox <gi...@apache.org>.
yu199195 commented on issue #9381:
URL: https://github.com/apache/shardingsphere/issues/9381#issuecomment-785693740
@maxh4 thanks good suggestion, SpringBootConfiguration (old ) need init other bean to spring-boot, so I think named ShardingSphereAutoConfiguration is reasonable. What do you think?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] terrymanu commented on issue #9381: sharding-jdbc-spring-boot-starter auto-configuration class better to rename
Posted by GitBox <gi...@apache.org>.
terrymanu commented on issue #9381:
URL: https://github.com/apache/shardingsphere/issues/9381#issuecomment-785634468
Sure, good suggestion, we are consider about change the class name for more make sense
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] maxh4 commented on issue #9381: sharding-jdbc-spring-boot-starter auto-configuration class better to rename
Posted by GitBox <gi...@apache.org>.
maxh4 commented on issue #9381:
URL: https://github.com/apache/shardingsphere/issues/9381#issuecomment-774846438
Hi @tristaZero ,
I didn't mean any conflicts. Just a naming strategy suggestion.
My project is in this structure:
|-RootProject
\-CommonModule
\-ServiceModule1
\-ServiceModule2
ServiceModules are all referencing the CommonModule, so that I can extract some common configurations to avoid redundant code.
Then I also need to write some tests in each module, so I have excluded the auto-configuration classes for features in Common, then import back in ServiceModules. This can start spring and run tests without configuration properties declared in the yaml file.
For other AutoConfiguration classes from the features I used, they are naming like:
SecurityAutoConfiguration.class,
DruidDataSourceAutoConfigure.class,
DataSourceAutoConfiguration.class,
RabbitAutoConfiguration.class
So here I suggest renaming the sharding sphere data source auto-configuration boot class to avoid confusions.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org