gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 22:11:17 33 4
gpt4 key购买 nike

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

pom.xml

<?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 解决了他们的问题。

@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;
}

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

The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

在我的 cmd 提示符中说:

the background cache eviction process was unable to free [10] percent of the cache for context. consider increasing maximum size of the cache ....approximately [9285] kb of data remained on the cache.

最佳答案

有多种解决方案:

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

更多详情 link

关于java - 后台缓存逐出进程无法为上下文释放 [10]% 的缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43135952/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com