Home > Back-end >  Java class doesn't have to match package written in source file
Java class doesn't have to match package written in source file

Time:11-07

in my project I wrote java class but by mistake put it into subfolder which is not same as mentioned package in source file. By chance I wrote this code not in some IDE therefore didn't noticed the mistake. My build system is maven and surprisingly the class was compiled and put into correct subdirectory of generated class files without any error. How can I configure maven compiler plugin or other maven plugin to recognize such mismatch when compile ?

CodePudding user response:

I found how I can prevent such mismatch - it can be done by using CheckStyle PackageDeclaration module(javadoc)

  • Related