Yes. Don't put Java source code in the webapp folder. Put it underneath the src/main/java folder.
The Maven compiler plugin will compile your classes and put them in the target/classes folder by default. From there, the Maven WAR plugin will put them in the WEB-INF/classes folder of the final WAR by default.
Don't try to do anything fancy. Just use Maven's source folders as they were intended and let Maven do the rest.
Stephan van Hulst wrote:I don't know what the purpose of the archetype is. When I looked at the directory structure it generates it seems pretty useless to me.
I never really use archetypes. I suggest you learn the Maven POM reference and set up your projects manually. It's not very difficult.
I started doing some introductory reading on how Maven expects directories and files to be set up... And you are right. It's not very difficult to set up your own projects but it is very tedious and takes a lot of reading.
I'm surprised they(Apache Maven) don't have a Maven tutorial called from the ground up -> Building your own Maven projects <-.
Incidentally, you defined your servlet in the Java default package and that's not recommended. It's better to define a package like com.coderanch.mywebapp and then create the file /src/main/java/com/coderanch/mywebapp/MyHelloWorld.java. Or probably more informatively as "MyHelloWorldServlet.java". But that's secondary.
The universal archetypes for Maven have been for me almost universally worthless. They're basically just template POMs that people have posted and are often out of date. Although by not including the JEE libraries at least you didn't have to choose between legacy and Jakarta JEE.
If I was defining prototype projects that incorporated local shop standards, I'd likely set up some archetypes in the shop's local repository for convenience. But, as I said, the universal ones aren't so great. Aside from general quality, for a lot of projects there are multiple candidates and no good documents on why you'd prefer one or the other.
Bjoke: A "Bully Joke". A Statement or action made with malicious intent - unless challenged. At which point it magically transforms into "I was just funnin'" or "What's the matter, can't take a joke?"