Disable scanManifest of Jar Scan in tomcat embed in spring boot

后端 未结 3 997
悲哀的现实
悲哀的现实 2021-02-13 20:57

I\'m getting some warnings in log, like this:

java.io.FileNotFoundException: C:\\Users\\user\\.m2\\repository\\com\\lowagie\\itext\\2.0.8\\bcmail-jdk14-138.jar (         


        
相关标签:
3条回答
  • 2021-02-13 21:08

    Edit: how about this?

      @Bean
      public EmbeddedServletContainerFactory embeddedServletContainerFactory() {
        return new TomcatEmbeddedServletContainerFactory() {
          @Override
          protected void postProcessContext(Context context) {
            ((StandardJarScanner) context.getJarScanner()).setScanManifest(false);
          }
        };
      }
    
    0 讨论(0)
  • 2021-02-13 21:21

    Just trying to improve Oleg's excellent answer about Spring Boot 1.x..

    Here's the corresponding code for Spring Boot 2.0 (Tomcat 8.5):

      @Bean
      public TomcatServletWebServerFactory tomcatFactory() {
        return new TomcatServletWebServerFactory() {
          @Override
          protected void postProcessContext(Context context) {
            ((StandardJarScanner) context.getJarScanner()).setScanManifest(false);
          }
        };
      }
    

    Just add that to your application's configuration.

    0 讨论(0)
  • 2021-02-13 21:28

    This is controllable via a property now:

    # Comma-separated list of additional patterns that match jars to ignore for TLD scanning.    
    server.tomcat.additional-tld-skip-patterns=*.jar
    

    via AFTER upgrade from Spring boot 1.2 to 1.5.2, FileNotFoundException during Tomcat 8.5 Startup

    0 讨论(0)
提交回复
热议问题