How to enable Java statements in Tomcat

I would like to use the Java assert keyword in my Spring web application, primarily on my classes (checking invariants inside constructors), but I don't see how to enable runtime statement validation.

For a regular Java application, I would use the -ea switch with the java command, but I don't see how to do this with Tomcat, etc.

Is this the recommended thing, or should I use the "Assert" class from the Spring framework? However, I prefer my domain classes to be free of Spring dependencies.

+6
source share
1 answer

For tomcat, add -ea to JAVA_OPTS (all running java processes) or even better CATALINA_OPTS (only for web application engine).

Read the catalina.bat or catalina.sh files for more information on JAVA_OPTS and CATALINA_OPTS .

Edited : thanks to @Joachim's comments

+8
source

Source: https://habr.com/ru/post/895410/


All Articles