简体   繁体   English

Cloud Foundry Java Buildpack:如何为Tomcat更改server.xml中的值?

[英]Cloud Foundry Java Buildpack : how to change value in server.xml for Tomcat?

I want to override the value maxPostSize property in the Connector element in the server.xml configuration file. 我想覆盖server.xml配置文件中Connector元素中的maxPostSize属性值。 (Set the maximum size to 1MB) (将最大大小设置为1MB)

Is the only way to do this to fork the https://github.com/cloudfoundry/java-buildpack and change the existing server.xml configuration file ? 这样做的唯一方法是派生https://github.com/cloudfoundry/java-buildpack并更改现有的server.xml配置文件?

Or is it also possible to add a server.xml somewhere in my WAR file, so that this one will be used instead of the one which is present in the buildpack. 或者也可以在我的WAR文件中的某处添加server.xml ,以便使用该文件而不是buildpack中的文件。

Or can I also use JAVA_OPTS for that ? 还是可以为此使用JAVA_OPTS?

Is the only way to do this to fork the https://github.com/cloudfoundry/java-buildpack and change the existing server.xml configuration file ? 这样做的唯一方法是派生https://github.com/cloudfoundry/java-buildpack并更改现有的server.xml配置文件?

With version 3.7+ of the Java build pack you can override the Tomcat configuration without forking the build pack. 使用Java构建包的3.7+版本,您可以覆盖Tomcat配置,而无需派生构建包。 The feature is called "External Tomcat Configuration". 该功能称为“外部Tomcat配置”。

https://github.com/cloudfoundry/java-buildpack/blob/master/docs/container-tomcat.md#external-tomcat-configuration https://github.com/cloudfoundry/java-buildpack/blob/master/docs/container-tomcat.md#external-tomcat-configuration

Here's the gist of how it works. 这是其工作原理的要点。

  • You make a TAR file of your tomcat/conf directory. 您创建了tomcat/conf目录的TAR文件。 This can contain things like server.xml , context.xml , web.xml and anything that would normally go under Tomcat's conf/ directory. 它可以包含server.xmlcontext.xmlweb.xml内容,通常包含在Tomcat的conf/目录下的任何内容。
  • You host an index.yml and that TAR file on an HTTP server some where. 您可以将index.yml和该TAR文件托管在HTTP服务器上的某个位置。 If you don't have one, you can push it as an application to CF using the Static File build pack. 如果您没有,则可以使用“静态文件”构建包将其作为应用程序推送到CF。
  • You point the Java build pack to this configuration repo with the environment variable JBP_CONFIG_TOMCAT . 您使用环境变量JBP_CONFIG_TOMCAT将Java构建包指向此配置JBP_CONFIG_TOMCAT Here is an example: `"{ tomcat: { external_configuration_enabled: true }, external_configuration: { repository_root: \\"url_to_repo\\" } }" 这是一个示例:`“ {tomcat:{external_configuration_enabled:true},external_configuration:{repository_root:\\” url_to_repo \\“}}”

More on the structure for the files on the HTTP server can be found here 有关HTTP服务器上文件结构的更多信息,请参见此处

I believe this will document all of your official options: https://github.com/cloudfoundry/java-buildpack/blob/master/docs/container-tomcat.md#additional-resources 我相信这将记录您所有的正式选择: https : //github.com/cloudfoundry/java-buildpack/blob/master/docs/container-tomcat.md#additional-resources

Neither of which are very simple/easy. 两者都不是非常简单/容易的。

You could consider changing your application to a spring boot application. 您可以考虑将您的应用程序更改为Spring Boot应用程序。 I'm not a boot expert but I believe that the java buildpack can use a boot embedded tomcat even even if the packaging type is a .war. 我不是启动专家,但我相信即使打包类型为.war,java buildpack也可以使用启动嵌入式tomcat。 In this type of configuration you might be able to use boot to customize how it starts the embedded tomcat to customize things like maxPostSize. 在这种类型的配置中,您可能能够使用boot来定制启动嵌入式tomcat的方式来定制诸如maxPostSize之类的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM