Java 后台缓存逐出进程无法为上下文释放[10]%的缓存

Java 后台缓存逐出进程无法为上下文释放[10]%的缓存,java,maven,tomcat,caching,spring-boot,Java,Maven,Tomcat,Caching,Spring Boot,我正在尝试在我的服务器上部署spring启动应用程序。我将WAR文件保存在Tomcat的webapps文件夹中 pom.xml 但就我而言,这也不起作用。每当我在浏览器上运行localhost:8080/privilance时,都会显示: 源服务器找不到目标的当前表示形式 资源或不愿意透露其存在 在我的命令提示符中说: 后台缓存逐出过程无法释放[10]个百分点 上下文的缓存。考虑增加最大尺寸 缓存…缓存上保留了大约[9285]kb的数据 你在cmd中得到的可能是警告?我认为这可能与web.xml

我正在尝试在我的服务器上部署spring启动应用程序。我将WAR文件保存在Tomcat的webapps文件夹中

pom.xml 但就我而言,这也不起作用。每当我在浏览器上运行
localhost:8080/privilance
时,都会显示:

源服务器找不到目标的当前表示形式 资源或不愿意透露其存在

在我的命令提示符中说:

后台缓存逐出过程无法释放[10]个百分点 上下文的缓存。考虑增加最大尺寸 缓存…缓存上保留了大约[9285]kb的数据


你在cmd中得到的可能是警告?我认为这可能与web.xml中的资源配置有关。请看。希望有帮助。

有多种解决方案:

  • 增加缓存(推荐)
  • 降低TTL(不推荐)
  • 抑制缓存日志警告(不推荐)
  • 禁用缓存

关于这方面的更多详细信息

我使用的是spring boot,我没有与问题无关的web.xml,但PDFBox的当前版本是2.0.5,而不是2.0.0。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.privilance</groupId>
<artifactId>privilance_survey</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<name>privilance_survey</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.2.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>net.sf.barcode4j</groupId>
        <artifactId>barcode4j</artifactId>
        <version>2.1</version>
    </dependency>
    <!--     
    <dependency>
        <groupId>net.sourceforge.nekohtml</groupId>
        <artifactId>nekohtml</artifactId>
        <version>1.9.21</version><!--$NO-MVN-MAN-VER$-->
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.pdfbox/pdfbox -->
    <dependency>
        <groupId>org.apache.pdfbox</groupId>
        <artifactId>pdfbox</artifactId>
        <version>2.0.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.1</version>
    </dependency>
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>itextpdf</artifactId>
        <version>5.5.11</version>
    </dependency>
</dependencies>
<build>
    <finalName>privilance</finalName>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
@Bean
public EmbeddedServletContainerFactory servletContainer() {
    TomcatEmbeddedServletContainerFactory tomcatFactory = new TomcatEmbeddedServletContainerFactory() {
        @Override
        protected void postProcessContext(Context context) {
            final int cacheSize = 40 * 1024;
            StandardRoot standardRoot = new StandardRoot(context);
            standardRoot.setCacheMaxSize(cacheSize);
            context.setResources(standardRoot); // This is what made it work in my case.

            logger.info(String.format("New cache size (KB): %d", context.getResources().getCacheMaxSize()));
        }
    };
    return tomcatFactory;
}