Java SpringBootMaven插件-jvm参数-直接内存大小设置
我正在使用spring boot maven plugin使用以下命令从我的应用程序构建docker映像:Java SpringBootMaven插件-jvm参数-直接内存大小设置,java,spring-boot,docker,maven-plugin,jvm-arguments,Java,Spring Boot,Docker,Maven Plugin,Jvm Arguments,我正在使用spring boot maven plugin使用以下命令从我的应用程序构建docker映像: spring-boot::build-image 我需要使用以下jvm参数更改jvm直接内存的默认大小(默认值为10m): -XX:MaxDirectMemorySize=64M 这是我在应用程序的pom.xml中不顾一切的尝试,我尝试了我想到的一切: <plugin> <groupId>org.springframework.b
spring-boot::build-image
我需要使用以下jvm参数更改jvm直接内存的默认大小(默认值为10m):
-XX:MaxDirectMemorySize=64M
这是我在应用程序的pom.xml
中不顾一切的尝试,我尝试了我想到的一切:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<configuration>
<jvmArguments>-XX:MaxDirectMemorySize=64M</jvmArguments>
<environmentVariables>
<JAVA_TOOL_OPTIONS>-XX:MaxDirectMemorySize=64M</JAVA_TOOL_OPTIONS>
<JAVA_OPTS>-XX:MaxDirectMemorySize=64M</JAVA_OPTS>
</environmentVariables>
<systemPropertyVariables>
<JAVA_TOOL_OPTIONS>-XX:MaxDirectMemorySize=64M</JAVA_TOOL_OPTIONS>
<JAVA_OPTS>-XX:MaxDirectMemorySize=64M</JAVA_OPTS>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
<configuration>
<layers>
<enabled>true</enabled>
</layers>
<image>
<name>docker.io/example/${project.artifactId}:${project.version}</name>
</image>
<excludeDevtools>true</excludeDevtools>
<systemPropertyVariables>
<JAVA_TOOL_OPTIONS>-XX:MaxDirectMemorySize=64M</JAVA_TOOL_OPTIONS>
<JAVA_OPTS>-XX:MaxDirectMemorySize=64M</JAVA_OPTS>
</systemPropertyVariables>
<environmentVariables>
<JAVA_TOOL_OPTIONS>-XX:MaxDirectMemorySize=64M</JAVA_TOOL_OPTIONS>
<JAVA_OPTS>-XX:MaxDirectMemorySize=64M</JAVA_OPTS>
</environmentVariables>
<jvmArguments>-XX:MaxDirectMemorySize=64M -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005</jvmArguments>
</configuration>
</plugin>
谁能告诉我我做错了什么
注:
弹簧靴:2.3.7.1释放
当我使用-e
手动运行docker image时,jvm参数的更改正在工作:
docker run -e JAVA_TOOL_OPTIONS=-XX:MaxDirectMemorySize=64M docker.io/example/app-name:0.0.1
此mvn插件正在使用Buildpack创建docker映像:
更新:
根据文档,这应该是有效的解决方案,但不是:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layers>
<enabled>true</enabled>
</layers>
<image>
<name>docker.io/example/${project.artifactId}:${project.version}</name>
<env>
<JAVA_TOOL_OPTIONS>-XX:MaxDirectMemorySize=64M</JAVA_TOOL_OPTIONS>
</env>
</image>
</configuration>
org.springframework.boot
springbootmaven插件
真的
docker.io/example/${project.artifactId}:${project.version}
-XX:MaxDirectMemorySize=64M
这取决于你在这里的目标。听起来你想在应用程序运行时更改容器中的最大直接内存,所以你应该只做你在此处指出的工作(以及文档中列出的工作)
docker运行-e JAVA\u TOOL\u OPTIONS=-XX:MaxDirectMemorySize=64M docker.io/example/app name:0.0.1
您正在引用的文档链接讨论的是在运行时配置选项,这就是您对环境变量所做的操作。这是一个关于如何使运行时环境“粘性”的有效解决方案:
。。。。
docker.io/example/${project.artifactId}:${project.version}
-XX:MaxDirectMemorySize=64M
...
spring boot maven插件正在使用paketo构建包:
文件:
看起来不同,但几乎与相同
JAVA\u工具\u选项
是一个运行时环境变量,因此需要通过docker run--env
传递给容器,该容器由spring boot maven插件
构建。
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layers>
<enabled>true</enabled>
</layers>
<image>
<name>docker.io/example/${project.artifactId}:${project.version}</name>
<env>
<JAVA_TOOL_OPTIONS>-XX:MaxDirectMemorySize=64M</JAVA_TOOL_OPTIONS>
</env>
</image>
</configuration>
....
<image>
<name>docker.io/example/${project.artifactId}:${project.version}</name>
<env>
<BPE_APPEND_JAVA_TOOL_OPTIONS>-XX:MaxDirectMemorySize=64M</BPE_APPEND_JAVA_TOOL_OPTIONS>
<BPE_DELIM_JAVA_TOOL_OPTIONS xml:space="preserve"> </BPE_DELIM_JAVA_TOOL_OPTIONS>
</env>
</image>
...