Spring-boot, tomcat-embedded — how define catalina.properties?

六眼飞鱼酱① 提交于 2019-12-12 17:15:19

问题


When running spring-boot with tomcat-embedded, how do I set/change these tomcat-config system-properties?

  • https://tomcat.apache.org/tomcat-8.5-doc/config/systemprops.html

I tried just adding -D... on the commandline, but doesnt seem to work.


回答1:


I am currently defining one of the catalina.properties via command line when starting my spring-boot application.

The property we are adding is: tomcat.util.http.parser.HttpParser.requestTargetAllow

The complete command I use to run the application is:

mvn -Dtomcat.util.http.parser.HttpParser.requestTargetAllow={} spring-boot:run

You should be able to append more catalina properties as follows:

mvn -Dtomcat.util.buf.StringCache.byte.enabled=true -Dtomcat.util.http.parser.HttpParser.requestTargetAllow={} spring-boot:run

And you could add any of the properties you mentioned here: https://tomcat.apache.org/tomcat-8.5-doc/config/systemprops.html

I ended up with this solution with the help of following posts:

https://bz.apache.org/bugzilla/show_bug.cgi?id=60594

Invalid character found in the request target in spring boot

Let me know if it works for you.




回答2:


I put the -D properties in the .conf like such:

JAVA_OPTS="$JAVA_OPTS -Dtomcat.util.http.parser.HttpParser.requestTargetAllow={}

That's the way you do it for deployments, the maven style by Alvaro Lazaro is more for development purposes.



来源:https://stackoverflow.com/questions/44379278/spring-boot-tomcat-embedded-how-define-catalina-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!