I'm using spring social authentication in a spring boot application. To persist the social user details I'm trying to use mysql with JdbcUsersConnectionRepository
.
我在spring启动应用程序中使用spring社交身份验证。为了保持社交用户的详细信息,我正在尝试将mysql与JdbcUsersConnectionRepository一起使用。
I need to change the table name which is by default set to prefix + UserConnect
. The table name and all the column names are in camel naming convention. But in my application, database columns are in underscore naming convention.
我需要更改默认设置为前缀+ UserConnect的表名。表名和所有列名都在camel命名约定中。但在我的应用程序中,数据库列采用下划线命名约定。
When I checked the sourcecode of JdbcUsersConnectionRepository
it's hard coded like below
当我检查JdbcUsersConnectionRepository的源代码时,它的硬编码如下
jdbcTemplate.queryForList("select userId from " + tablePrefix + "UserConnection where providerId = ? and provide....
I know i can rewrite the UsersConnectionRepository
implementation and do this. Which is actually i'm doing at the moment.
我知道我可以重写UsersConnectionRepository实现并执行此操作。实际上我现在正在做这件事。
public class SecUsersConnectionRepository implements UsersConnectionRepository {
private UserRepository userRepository;
private UserConnectionRepository userConnectionRepository;
private ConnectionFactoryLocator connectionFactoryLocator;
.....
.....
But in this way i have to rewrite the same logic in JdbcUsersConnectionRepository
again. Which is not productive at all. So what is the best practice to achieve this?
但是这样我必须再次在JdbcUsersConnectionRepository中重写相同的逻辑。这完全没有效率。那么实现这一目标的最佳做法是什么?
I hope I'm not the only one who faces such issue with spring social. Please share your knowledge on how you solve such situation.
我希望我不是唯一一个面临春季社交问题的人。请分享您对如何解决此类情况的了解。
1 个解决方案
#1
This is not currently possible I'm afraid because, as you rightly pointed out, it's hardcoded in Spring code.
目前这不可能我担心,因为正如你正确指出的那样,它在Spring代码中是硬编码的。
Check the official response Spring forum
查看官方回复Spring论坛
If you don't want to replicate code, you must stick to spring's default table name. This is what I did in my project.
如果您不想复制代码,则必须坚持使用spring的默认表名。这就是我在项目中所做的。
Cheers.
#1
This is not currently possible I'm afraid because, as you rightly pointed out, it's hardcoded in Spring code.
目前这不可能我担心,因为正如你正确指出的那样,它在Spring代码中是硬编码的。
Check the official response Spring forum
查看官方回复Spring论坛
If you don't want to replicate code, you must stick to spring's default table name. This is what I did in my project.
如果您不想复制代码,则必须坚持使用spring的默认表名。这就是我在项目中所做的。
Cheers.