window的war发布Linux失败,为什么war包在Windows的tomcat正常运行,在linux服务器报errorpage错误?...

最近项目完成后打包成war发布到服务器遇到访问应用404问题,用的是tomcat8.5,错误信息如下:

o.s.b.w.servlet.support.ErrorPageFilter  : Cannot forward to error page for request [/login] as the response has already been committed. As a result, the response may have the wrong status code. If your application is running on WebSphere Application Server you may be able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false

项目是springboot+security+mybatis,ide 用的idea,打包方式用的是build菜单中的Build Artifactis

security配置protected void configure(HttpSecurity http) throws Exception {

http.authorizeRequests()

//处理preflight请求

//.requestMatchers(CorsUtils::isPreFlightRequest).permitAll()

.antMatchers("/user/login").permitAll()

.antMatchers("/login").permitAll()

.antMatchers("/login/error").permitAll()

.anyRequest().authenticated()

.and()

//设置登录页

.formLogin()

//设置登录成功页

.loginPage("/login")

.successHandler(securityLoginSuccessHandler)

.failureHandler(securityLoginFailureHandler)

.and()

.logout()

.logoutUrl("/logout")

.logoutSuccessHandler(securityLogoutSuccessHandler)

.deleteCookies("JSESSIONID")

.and()

.sessionManagement()

//session超时处理

.invalidSessionUrl("/login/invalid")

.maximumSessions(1)

//老用户被踢出后操作

.expiredSessionStrategy(new SecurityExpiredSessionStrategy());

http.csrf().disable()

.exceptionHandling().accessDeniedHandler(securityAccessDeniedHandler);

}

loginpage的“/login”配置如下:@RequestMapping("/login")

public String  showLogin() throws IOException {

System.out.println("调用loginController的登录方法");

return "index.html#/login";

}

这篇博客在启动类加入配置:public class KpApplication extends SpringBootServletInitializer {

public static void main(String[] args) {

SpringApplication.run(KpApplication.class, args);

}

@Bean

public ErrorPageFilter errorPageFilter() {

return new ErrorPageFilter();

}

@Bean

public FilterRegistrationBean disableSpringBootErrorFilter(ErrorPageFilter filter) {

FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();

filterRegistrationBean.setFilter(filter);

filterRegistrationBean.setEnabled(false);

return filterRegistrationBean;

}

}

重新打包发布到linux服务器,新的错误信息为:

o.s.b.d.LoggingFailureAnalysisReporter   :

***************************

APPLICATION FAILED TO START

***************************

Description:

The bean 'errorPageFilter', defined in org.springframework.boot.web.servlet.support.ErrorPageFilterConfiguration, could not be registered. A bean with that name has already been defined in com.kpzdh.kp.KpApplication and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=truespring:

jmx:

default-domain: demo

datasource:

driver-class-name: com.mysql.cj.jdbc.Driver

url: jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8

username: root

password: root

main:

allow-bean-definition-overriding: true

如上配置之后,两个错误信息都没有出现了,但是还是404,查看日志,"/login"路径的"调用loginController的登录方法"已经输出了,

但是浏览器控制台中,/login路径还是404,请问该如何解决呢?

这个问题已经困扰很久了,希望大家能帮帮我,万分感谢!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值