我不断得到下面的错误,我确实启用了@enabletransactionmanagement事务,但仍然不知何故,事务没有在defaulttokenservices中调用。
任何帮助都将不胜感激
注意:它与springboot1.5一起工作,最近我升级到了2.1
2020-11-19 18:27:12.385 ERROR 49065 [tomcat-exec-2] - o.s.s.o.provider.endpoint.TokenEndpoint : Handling error: TransientDataAccessResourceException, PreparedStatementCallback; SQL [insert into oauth_access_token (token_id, token, authentication_id, user_name, client_id, authentication, refresh_token) values (?, ?, ?, ?, ?, ?, ?)]; Connection is read-only. Queries leading to data modification are not allowed; nested exception is java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
org.springframework.dao.TransientDataAccessResourceException: PreparedStatementCallback; SQL [insert into oauth_access_token (token_id, token, authentication_id, user_name, client_id, authentication, refresh_token) values (?, ?, ?, ?, ?, ?, ?)]; Connection is read-only. Queries leading to data modification are not allowed; nested exception is java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:110)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
1条答案
按热度按时间pwuypxnk1#
解决方案
我可以通过手动将事务附加到OAuthJDBCtokenService来修复hack。
我还创建了一个关于springsecurityoauth的问题,但似乎它不应该支持springboot2.x。
任何聪明的人都想知道为什么事务不能在defaulttokenservices中调用。
解决方案
为defaulttokenservices创建bean并将其传递给配置程序
链接:https://github.com/spring-projects/spring-security-oauth/issues/1900