simply create a
java directory under
src/main/java) and right-click on your project and select maven > update project configuration.
error occurs when the jre system library is wrongly pointed. now go to libraries tab and change the jre system library to the correct version.
in intellij idea 13 you must first create "java" folder in main folder then --> go to "open module setting"- for this you can click on project name and press f4- , and set label of "java" folder to "source" .
here is my solution. it works without any issue.
there could be questions regarding why all this steps are required and i believe they are pretty genuine. but this is one of the ways to make your web application or any other component working on eclipse using maven from command line.
1) open a command window
2) mvn archetype:generate -dgroupid=your package -dartifactid=your project -darchetypeartifactid= your archetype. in my case "maven-archetype-webapp" -dinteractivemode=false
3) cd your project
4) mvn eclipse:eclipse -dwtpversion=2.0
5) go to file system. go to your newly created project. create folders,
a) java under main
b) test under src c) java and resources under test
6) mvn eclipse:clean
7) mvn eclipse:eclipse -dwtpversion=2.0
8) import your project project in eclipse
do it the other way around. first make a webapp project, then add the maven framework (in intellij - right click project and select add framework support). it will create the right folders for you.
i had the same problem even when i added jre system library to my current java version but still had same problem then i just deleted jre system library and added once again it worked for me
to delete jre system library right click on project ->properties ->java build path -> select jre system library -> remove
to add jre go to properties->java build path -> add library ->jre system library -> choose jre -> finish
just add a new folder "java" under src/main. will solve the problem. because the classpath with java folder is already available in .classpath file of created project, so adding java folder will not cause any error. see below entry in .classpath file, which allows to add java folder.
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
following steps work in eclipse 2020-06
- file->new->maven project
- choose "create a simple project (skip archetype selection)"
- choose packaging as "war" (this will create both webapp and java folders)
- create the project after specifying group id and artifact id
- update pom.xml with java and compiler versions, then right click on project, select maven->update project
- if the project is not faceted form (its not in faceted form if on expanding project in project explorer, it doesn't show details such as "deployment descriptor" and "jax-ws web services", this happened in one of my eclipse installation and i had no clue why), then do the following steps
- right click on project, go to properties, click on project facets, convert to faceted form, choose correct "dynamic web module" version, enable the checkbox and also choose correct java facet version.
- "further configuration available" gets displayed in that window, click on it and specify webcontent folder. (replace webcontent by src/main/webapp)
- if you want to run the application in servers configured in eclipse, then specify maven dependencies to be deployed in "deployment assembly". this will deploy maven "provided" dependencies also, but i think its fine for testing. for actual distribution, you can supply war file generated from maven package.
there is an option to create a source directory in eclipse. or you can go to build path under project properties, and add an existing directory as a source directory.
if you are going to use non-standard directory structure you will have to specify it in maven though
a webapp structure gets generated but with no 'java' directory under main
create src/main/java on your own.
furthermore, there seems to be no compilation of it by java. i can make stupid errors and no syntax highlighting comes up. it's like java isn't recognizing it.
after creating appropriate dir structure execute the maven command
then refresh the project in eclipse.
your project >> properties >> java build path >> source >>
search "your project src/main/java (missin)" >>>
edit > folder name >> next >> inclusion patterns: -----> add >> src/main/java ok
and if errors still don't disapear
>>> look in target runtimes and check your apache in checkbox
right click the maven project -> build path -> configure build path in order & export tab, you can see the message like select 'jre system library' and 'maven dependencies' checkbox click ok now you can them
this is a great article that i read when i was having trouble understanding how to build multiple projects into one using maven. specifically, this article explains how to set up a web project (war file) to consume an inner standard java project (jar file).
if you have a basic understanding of maven, skip to the sections at the end: how do i build other types of projects? how do i build more than one project at once?
if you aren't familiar with maven yet, check out:
trust me, mkyong knows what is up!
simply create new folder named java under src/main/
then right click on project and select maven->update project
- read the m2eclipse wtp mini-howto.
- check the online developing with eclipse and maven.
- ensure your settings.xml is configured in the eclipse preferences.
- check the m2eclipse faq.
anything else is likely to be down to the archetype and how you've configured your
pom.xml. the directory structure you describe is identical to the one
maven-archetype-webapp creates on the command line.
simply create a java directory under main (i.e. src/main/java) and right-click -> build path -> use a source folder
- by default, when you create a project with maven archetype "maven-archetype-webapp", it doesn't create any java and test folders.
- you can manually add those folders as src/main/java and src/test/java.
- after adding these folders, right click on your project in project explorer, go to maven>update project conf.
- reference applet class in Maven webapp archetype eclipse classnotfound exception
- How can I run a Maven webapp in Eclipse when I use profiles to populate properties files at build time?
- Using maven android archetype with eclipse
- Problem with Eclipse and a Maven multi-module project
- Problem installing Maven plugin (m2eclipse) in Eclipse (Galileo)
- Eclipse Maven Plugin Configuration Problem
- Problem with running Maven GWT application in Eclipse
- Eclipse Java EE New Maven Project: Could not resolve archetype
- Use webapp classpath using JavaCompiler in Tomcat within Eclipse with Maven
- Can't get compile on save / hot deploy feature to work with maven based webapp in eclipse or netbeans
- Maven and Eclipse problem - looking for resources
- Maven webapp with Eclipse and WTP plugin deploy files in stranges ways in Tomcat
- Eclipse WebApp deploying over Maven with Tomcat results in Error: 'Failed to deploy application at context path'
- Create a maven webapp project using the eclipse kelper, I got an eclipse error
- How to run maven webapp from eclipse with embedded tomcat?
- How can I run a Maven webapp in Eclipse when I need resource filtering for properties files?
- Maven webapp archetype doesn't create java folder
- Unable to add camel archetype in a maven project in Eclipse
- Deploy GWT maven project with eclipse deploys webapp directory instead of target/project directory
- PlayN Maven Archetype and Running HTML5 in Eclipse
- How to solve an issue Eclipse not showing Javadocs for javax.annotation package in webapp-javaee7 archetype Maven project?
- Maven archetype generate and open in eclipse
- setting maven archetype using eclipse GUI
- eclipse maven plugin problem
- Run a java servlet maven webapp in tomcat in eclipse
- Run Maven webapp on server from Eclipse with properties injection from profile
- Eclipse not using the lastest snapshot in maven archetype project creation
- gwt maven plugin - unable to run archetype generated sample project in eclipse
- Eclipse Apache ISIS HelloWorld archetype errors: flatten, QHelloWorldObject, maven build java.sql.SQLException missing
- Maven project can not be created in Eclipse Neon using Archetype
More Query from same tag
- Eclipse Launch Group - How does Launch Mode work?
- How do I check installed JARs, external libraries, etc. on three different Java IDEs?
- Shortcut to close all tabs except pinned one in Eclipse
- Perl in eclipse: ant build
- Debugging breakpoints on JUnit test in Eclipse are not working
- checkstyle doesn't work on linux eclipse luna
- Mysql connection failure in JAVA
- I have eclipse luna, how do I add eclipse indigo?
- device not found
- Maven dependencies download only on command line and not in Eclipse
- Failing to compile/run Rascal example code
- How to stop view from reappearing on workbench restart?
- JGit: Status of remote repository
- How to integrate jars into maven project
- Program works in Eclipse debugger but not anywhere else...?
- Android: what is the use of static wifi ip in android device?
- Add jar to eclipse plugin
- How I do fix with IlegalStateException?
- C++ and undefined reference to XML_Parser
- Whats the shortcut to Debug in PyDev using Eclipse
- Eclipse CDT - problem linking to windows lib files
- Log4j cannot find properties file in a simple application
- relative Path for file in struts 2 Webapplication
- Displaying the execution script for a Java application in Eclipse
- corrupted ELF header/section after extract from eclipse bundle
- fix importing errors in Eclipse
- How to declare global dependency for all submodules with maven and eclipse
- Pure java alternative to GIMP with *live* plugin development?
- Eclipse xdebug session never completes and holds on 48%
- Servlet example - File not found