尝试使用spring安全版本5.4.6和java 12登录时发生异常

l5tcr1uw  于 2021-09-30  发布在  Java
关注(0)|答案(0)|浏览(149)

我有一个我曾经使用过的web应用程序。

org.springframework-version: 4.1.4.RELEASE
spring.security.version: 3.2.5.RELEASE
org.hibernate-version: 3.5.1-Final.
java-version 1.6

我正在尝试升级spring、java和hibernate版本,我在pom文件中成功地更新了以下内容

org.springframework-version: 5.3.6
spring.security.version: 5.4.6
org.hibernate-version: 5.4.31.Final
java-version -version: 11.0.2

我还更新了我提到的spring安全bean的相关xml文件。我用的是postgres数据库。我面临一个问题。当我输入用户名和密码,并单击submit按钮时,会显示405错误页面。控制台上没有显示任何错误消息。
我的spring-security.xml文件中的bean

<form-login login-page="/login" login-processing-url="/login" default-target-url="/"
            authentication-failure-url="/login?error" username-parameter="username"
            password-parameter="password" />
        <logout logout-success-url="/" invalidate-session="false"/>

        <beans:bean id="daoAuthenticationProvider"
 class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
  <beans:property name="userDetailsService" ref="userDetailsService"/>
</beans:bean>

<beans:bean id="authenticationManager"
    class="org.springframework.security.authentication.ProviderManager">
 <beans:constructor-arg> 
    <beans:list>
      <beans:ref bean="daoAuthenticationProvider" />
    </beans:list>
  </beans:constructor-arg>
</beans:bean>

    <!-- Declare an authentication-manager to use a custom userDetailsService -->
    <authentication-manager>
        <authentication-provider user-service-ref="userDetailsService">
        <password-encoder hash="bcrypt" />
        </authentication-provider>
    </authentication-manager>

我的userserviceimpl

@Service("userDetailsService")
public class UserServiceImpl implements UserDetailsService, UserService {
@Transactional(readOnly = true)
    public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundException, DataAccessException {

        String siteDomainName = (String) request.getServerName();
        logger.info("A user trying to login in domainnName " + siteDomainName+" with username/email "+userName);
        Site site = null;
        try {
            <!-- codes-->
        } catch (SiteManagerException e) {
            <!--error message-->
        }

    }

登录控制器

@RequestMapping(value = "/login", method = RequestMethod.GET)
        public String login(ModelMap model, @RequestParam(value = "error", required = false) String error, @RequestParam(value = "logout", required = false) String logout)
        {
            try
            {
                 <!-- codes-->
            }
            catch(Exception ex)
            {
                <!--error message-->
            }
        }

谁能帮我解决这个问题?谢谢
登录时出错

20210610-09:25:25.108 sitepm-service [http-nio-8036-exec-9] ERROR o.h.e.jdbc.spi.SqlExceptionHelper.logExceptions - This method is not yet implemented.

20210610-09:25:25.108 sitepm-admin [http-nio-8036-exec-9] ERROR o.h.e.jdbc.spi.SqlExceptionHelper.logExceptions - This method is not yet implemented.
20210610-09:25:25.110 sitepm-service [http-nio-8036-exec-9] ERROR c.s.a.u.controller.LoginController.setExceptionPage - org.hibernate.exception.GenericJDBCException: could not prepare statement

20210610-09:25:25.110 sitepm-admin [http-nio-8036-exec-9] ERROR c.s.a.u.controller.LoginController.setExceptionPage - org.hibernate.exception.GenericJDBCException: could not prepare statement

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题