HowToDoInJava

  • Python
  • Java
  • Spring Boot
  • Dark Mode
Home / Maven / Creating java source folders

Maven – Create java source folders

This is very strange problem but this is fact that when you create a maven web application using “-DarchetypeArtifactId=maven-archetype-webapp” then no java source folder is created. Rather a resources folder is created. Files placed in resources folder are placed in your classpath when war file is created for your web application.

To create java source folders, you MUST create them manually. And then add these folders to your build configuration later.

1) Create maven web application

To Create maven web application , run below command in your working directory.

//No line breaks in below command

mvn archetype:generate -DgroupId=com.howtodoinjava.demo -DartifactId=springmvcexample -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false

2) Above command will maven specific folder structure for a web application inside working directory. Now add eclipse support (or support for your favorite IDE) into this web application with below command.

//Change current working directory to application folder
cd springmvcexample

//add eclipse support
mvn eclipse:eclipse

3) Import the web application into eclipse as existing maven project

import-existing-maven-project

import-existing-maven-project-step-2

default-maven-directory-structure

4) Create source folders manually [Yeh !! Need to do it manually]

add-new-folders-in-maven-web-project

5) Update project build configuration with command Maven > “Update Project”

update-maven-project

updated-source-folders

That’s all. Your source folders are ready.

Happy Learning !!

Share this:

  • Twitter
  • Facebook
  • LinkedIn
  • Reddit

About Lokesh Gupta

A family guy with fun loving nature. Love computers, programming and solving everyday problems. Find me on Facebook and Twitter.

Comments are closed on this article!

Search Tutorials

Maven Tutorial

  • Maven – Installation
  • Maven – Settings
  • Maven – Dependency Mgmt
  • Maven – Dependency Scopes
  • Maven – POM
  • Maven – Parent POM
  • Maven – Repositories
  • Maven – Local Repo Path
  • Maven – M2_REPO
  • Maven – Network Proxy
  • Maven – Enforce Java Versions
  • Maven – Simple Java Project
  • Maven – Web Project
  • Maven – Multi-module Project 1
  • Maven – Multi-module Project 2
  • Maven – Java Source Folders
  • Maven – BOM [Bill Of Materials]
  • Maven – Import Remote Catalogs
  • Maven – Create Custom Archetype
  • Maven – Compiler Level Mismatch
  • Maven – Ant Build
  • Maven – IntelliJ
  • Maven – JSTL Support
  • Maven – Tomcat Plugin
  • Maven – Uber Jar for Spring Boot
  • Maven – Shade Plugin
  • Maven – Remove corrupt jars

Meta Links

  • About Me
  • Contact Us
  • Privacy policy
  • Advertise
  • Guest and Sponsored Posts

Recommended Reading

  • 10 Life Lessons
  • Secure Hash Algorithms
  • How Web Servers work?
  • How Java I/O Works Internally?
  • Best Way to Learn Java
  • Java Best Practices Guide
  • Microservices Tutorial
  • REST API Tutorial
  • How to Start New Blog

Copyright © 2020 · HowToDoInjava.com · All Rights Reserved. | Sitemap

  • Java 15 New Features
  • Sealed Classes and Interfaces
  • EdDSA (Ed25519 / Ed448)