I would like to use the Java assert keyword in my Spring web-app, primarily on my domain classes (checking invariants within constructors), but I cannot see how to enable runtime assertion checking.
For a normal java application, I would use the -ea switch with the java command, but I don’t see how I can do that with Tomcat, etc.
Is this the recommended thing, or should I use the “Assert” class from the Spring framework? I’d rather keep my domain classes free of Spring dependencies, however.
For tomcat, add
-eatoJAVA_OPTS(all java processes started), or even better toCATALINA_OPTS(only to web app engine).Read the files
catalina.batorcatalina.shfor more information onJAVA_OPTSandCATALINA_OPTS.Edited: Thanks to comments from @Joachim