我是heroku
的新手,最近我在spring mvc上使用java配置构建了一个简单的应用程序。
所以我使用github在heroku上部署了这个应用程序。
我使用mysql
作为数据库。
我的连接看起来像这样: -
@Bean
public DataSource dataSource() throws URISyntaxException {
URI dbUri = new URI(System.getenv("CLEARDB_DATABASE_URL"));
String username = dbUri.getUserInfo().split(":")[0];
String password = dbUri.getUserInfo().split(":")[1];
String dbUrl = "jdbc:mysql://eu-cdbr-west-
01.cleardb.com:3306/heroku_eb3825f7cae7006?reconnect=true";
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setUrl(dbUrl);
dataSource.setUsername(username);
dataSource.setPassword(password);
return dataSource;
}
该应用已成功部署,我可以查看登录页面。我连接数据库以检查是否所有表都是自动创建的。创建了所有表,所以我在user
和user_role
表中插入了一些值,但现在当我尝试登录时,我无法登录。
错误日志说: -
\ Hibernate:
: select
: user0_.id as id1_1_,
: user0_.enabled as enabled2_1_,
: user0_.password as password3_1_,
: user0_.username as username4_1_
: from
: lashes.users user0_
: where
: user0_.username=?
: 2018-01-04 15:19:48 [http-nio-35848-exec-9] WARN :: SQL Error: 1142, SQLState: 42000
: 2018-01-04 15:19:48 [http-nio-35848-exec-9] ERROR:: SELECT command denied to user 'bd427bc263a111'@'ip-10-84-26-33.eu-west-1.compute.internal' for table 'users'
: 2018-01-04 15:19:48 [http-nio-35848-exec-9] ERROR:: An internal error occurred while trying to authenticate the user.
: org.springframework.security.authentication.InternalAuthenticationServiceException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
:at org.springframework.security.authentication.dao.DaoAuthenticationProvider.retrieveUser(DaoAuthenticationProvider.java:126)
:at org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:144)
:at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:174)
:at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:199)
:at org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter.attemptAuthentication(UsernamePasswordAuthenticationFilter.java:94)
:at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:212)
:at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
:at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
:at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
:at org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:124)
:at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
: Caused by: org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
: at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:261)
: at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:244)
: at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:488)
: at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59)
: at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
: at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147)
: at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
: at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
: at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
2018-01-04T15:19:48.984999+00:00 app[web.1]: at com.sun.proxy.$Proxy55.findByUsername(Unknown Source)
at com.lashes.services.CustomUserDetailsService.loadUserByUsername(CustomUserDetailsService.java:28)
: at org.springframework.security.authentication.dao.DaoAuthenticationProvider.retrieveUser(DaoAuthenticationProvider.java:114)
Caused by: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
Caused by: java.sql.SQLSyntaxErrorException: SELECT command denied to user 'bd427bc263a111'@'ip-10-84-26-33.eu-west-1.compute.internal' for table 'users'