Java Spring引导第二次运行jar文件导致超时问题

Java Spring引导第二次运行jar文件导致超时问题,java,spring,maven,spring-boot,Java,Spring,Maven,Spring Boot,是的,你读对了。我做过几十次SpringBoot微服务,但从未遇到过这个问题 我已经为安全资源配置了spring安全性。我有正常的非安全页面。我正在使用springbootmaven插件构建jar 使用mvn包创建jar文件 使用scp将该文件推送到我的远程服务器 使用java-jar app.jar启动应用程序 一切正常。只是停止了这个过程 对外部属性做了一些更改,然后使用相同的命令重新开始 正在呈现非安全页面 安全页面重定向到/login,它从不呈现登录页面。导致页面超时 调试日志 2019

是的,你读对了。我做过几十次SpringBoot微服务,但从未遇到过这个问题

我已经为安全资源配置了spring安全性。我有正常的非安全页面。我正在使用
springbootmaven插件构建jar

  • 使用
    mvn包创建jar文件
  • 使用
    scp
    将该文件推送到我的远程服务器
  • 使用
    java-jar app.jar启动应用程序
  • 一切正常。只是停止了这个过程
  • 对外部属性做了一些更改,然后使用相同的命令重新开始
  • 正在呈现非安全页面
  • 安全页面重定向到/login,它从不呈现登录页面。导致页面超时
  • 调试日志

    2019-01-02 20:41:02.698 DEBUG 27713 --- [nio-8081-exec-1] o.s.web.servlet.DispatcherServlet        : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/admin/login]
    2019-01-02 20:41:02.706 DEBUG 27713 --- [nio-8081-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /login
    2019-01-02 20:41:02.711 DEBUG 27713 --- [nio-8081-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Returning handler method [public org.springframework.web.servlet.ModelAndView com.admin.SecuredPage.login(javax.servlet.http.HttpServletRequest,org.springframework.security.web.csrf.CsrfToken)]
    2019-01-02 20:41:02.712 DEBUG 27713 --- [nio-8081-exec-1] o.s.web.servlet.DispatcherServlet        : Last-Modified value for [/admin/login] is: -1
    2019-01-02 20:41:02.789 DEBUG 27713 --- [nio-8081-exec-1] o.s.w.s.v.ContentNegotiatingViewResolver : Requested media types are [text/html, application/xhtml+xml, image/webp, image/apng, application/xml;q=0.9, */*;q=0.8] based on Accept header types and producible media types [*/*])
    2019-01-02 20:41:02.805 DEBUG 27713 --- [nio-8081-exec-1] o.s.w.s.v.ContentNegotiatingViewResolver : Returning [org.springframework.boot.web.servlet.view.MustacheView: name 'login'; URL [classpath:/templates/login.html]] based on requested media type 'text/html'
    2019-01-02 20:41:02.807 DEBUG 27713 --- [nio-8081-exec-1] o.s.web.servlet.DispatcherServlet        : Rendering view [org.springframework.boot.web.servlet.view.MustacheView: name 'login'; URL [classpath:/templates/login.html]] in DispatcherServlet with name 'dispatcherServlet'
    
    Spring安全配置

    protected void configure(HttpSecurity http) throws Exception {
                http.authorizeRequests().antMatchers("/stylesheets/**").permitAll().and()
                .authorizeRequests().antMatchers("/register").permitAll().and()
                .authorizeRequests().antMatchers("/js/**").permitAll().and()
                .authorizeRequests().antMatchers("/images/**").permitAll().and()
                .authorizeRequests().antMatchers("/login").permitAll().anyRequest().authenticated().and()
                .formLogin().loginPage("/login").successHandler(successAuthHandler)
                .failureUrl("/login?error=401").permitAll().and()
                .logout().permitAll().and().csrf();
                http.sessionManagement().maximumSessions(1).expiredUrl("/login?error=ms").sessionRegistry(sessionRegistry());
            }
    
    登录方法

     @RequestMapping(value = "/login")
        public ModelAndView login(HttpServletRequest req, CsrfToken csrfToken) {
            Authentication auth = SecurityContextHolder.getContext().getAuthentication();
            if (!(auth instanceof AnonymousAuthenticationToken)) {
                return utilityComponent.getRedirectModelAndView("cats");
            }
            ModelAndView modelAndView = new ModelAndView();
            modelAndView.setViewName("login");
    
            CsrfToken csrf = (CsrfToken) req.getAttribute(CsrfToken.class.getName());
            modelAndView.addObject("_csrf", csrf);
            String errorParm = req.getParameter("error");
            System.out.println("I am tired");  
            return modelAndView;
        }
    
    它正在打印
    我累了
    ,没有任何问题

    版本

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.3.RELEASE</version>
    </parent>
    
    
    
    <properties>
        <maven.compiler.source>9</maven.compiler.source>
        <maven.compiler.target>9</maven.compiler.target>
        <maven.test.skip>true</maven.test.skip>
    </properties>
    
    WARNING: An illegal reflective access operation has occurred
    WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
    WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
    WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
    WARNING: All illegal access operations will be denied in a future release
    [INFO] Scanning for projects...
    [WARNING] 
    [WARNING] Some problems were encountered while building the effective model for com.admin:admin-app:jar:0.0.2
    [WARNING] 
    [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
    [WARNING] 
    [WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
    [WARNING] 
    [INFO] 
    [INFO] ----------< com.admin:admin-app >-----------
    [INFO] Building admin-app 0.0.2
    [INFO] --------------------------------[ jar ]---------------------------------
    [INFO] 
    [INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ admin-app ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 1 resource
    [INFO] Copying 102 resources
    [INFO] 
    [INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ admin-app ---
    [INFO] Nothing to compile - all classes are up to date
    [INFO] 
    [INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ admin-app ---
    [INFO] Not copying test resources
    [INFO] 
    [INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ admin-app ---
    [INFO] Not compiling test sources
    [INFO] 
    [INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ admin-app ---
    [INFO] Tests are skipped.
    [INFO] 
    [INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ admin-app ---
    [INFO] Building jar: /home/pasu/eclipse-workspace/admin-app/target/admin-app-0.0.2.jar
    [INFO] 
    [INFO] --- spring-boot-maven-plugin:2.0.3.RELEASE:repackage (default) @ admin-app ---
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 2.326 s
    [INFO] Finished at: 2019-01-02T19:35:15-06:00
    [INFO] ------------------------------------------------------------------------
    
    环境

    Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-38-generic x86_64)
    openjdk 10.0.2 2018-07-17
    OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4)
    OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4, mixed mode)
    

    我错过了什么

    您可以添加版本吗?更新了@Xentros,感谢您致电outSilly问:
    /login
    (您想要的)和
    /admin/login
    (我在日志中看到的)之间有什么区别?建议:1)停止并重新启动您的应用程序。可能不会修复任何问题-但这绝对是开始任何故障排除会话之前要尝试的第一件事。2) 设置日志级别=>TRACE。3) 在调试日志中发回跟踪级别信息。同样,4)考虑使用WiReSARK网络跟踪。WiReSurk对于Linux是绝对可用的。我自己使用:)如果你没有GUI桌面,或者你不能使用,那么试试看。另外:您是否已启用Spring并将loglevel设置为“跟踪”?若否,原因为何?
    Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-38-generic x86_64)
    openjdk 10.0.2 2018-07-17
    OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4)
    OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4, mixed mode)