日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

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

發布時間:2023/12/10 linux 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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,請問該如何解決呢?

這個問題已經困擾很久了,希望大家能幫幫我,萬分感謝!

總結

以上是生活随笔為你收集整理的window的war发布Linux失败,为什么war包在Windows的tomcat正常运行,在linux服务器报errorpage错误?...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。