IDEA resource files missing after updating - java

Files miss from the target folder After I update these files in resource folder.The IDE is IDEA and the project is maven project.
Here is the picture of project files
the project files
Here is the configuration of the IDEA project structure
the IDEA project structure
Can't figure out where the problem is.

Try re import all maven project option from maven dialog box.

target folder is generated by maven install.
Unless you have something explicitilly removing them they should appear normally when runnig mvn clean install.
https://maven.apache.org/plugins/maven-resources-plugin/examples/include-exclude.html

Related

Eclipse project not reading depdencies inside the POM file

In Eclipse Neon, I did an 'import existing maven project' from a local folder, whose content was copied from another machine. The project is not reading the dependencies on the POM file, and one example is the log4j dependency. A workaround is to add the log4j-1.2.17.jar manually to the project as an external jar, but this is wrong. Does anyone have tips on how to troubleshoot? I am fairly inexperienced with maven so I m not sure if there are additional settings or configuration that I have do when importing an existing project into eclipse.
You can make sure if your project dependencies are being pulled correctly or not by executing
mvn clean install
from within the project directory on the command line. This would download the required dependencies of the project as well.
The most common cause I have seen for this issue occurs whenever Maven encountered an error while downloading an artifact from a repository. In this case, Maven marks the download as failed and won't retry until some time elapses (I do not remember how long).
The easiest way to test this is to delete the .m2/repository folder in your home directory and let Maven download the artifacts again. If you have Maven installed you just execute "mvn install" from a console. Otherwise, you can try:
Right click the project in Eclipse
Select "Maven > Update Project"
Check "Force Update of Snapshots/Releases"
Click "OK"

Eclipse project and Maven pom file not in same directory

I have a project in Eclipse for which the Pom file(pom.xml) and Eclipse project file(.project) are not in the same directory. The Pom file is next to the source code.
The project resources in Eclipse are defined as Linked Resources(http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Fconcepts%2Fconcepts-13.htm).
I added the pom file as a Linked Resource then and converted the project in Eclipse to a Maven project(Configure -> Convert to Maven Project).
Unfortunately Eclipse is not showing the Maven Dependencies for that project and these are not resolved. Just having the Eclipse project file next to the pom and resources works well for that project but I cannot eventually use it(it's a company rule).
Tanks a lot in advance for your help
Unfortunately Eclipse is not showing the Maven Dependencies for that
project and these are not resolved.
Yeah, and I believe that the Eclipse project files are not going to pick up your changes when you convert to a maven project. This is simply the way maven works because you have the .project file elsewhere.
One note may be helpful: it is generally considered bad practice to check in your .project & .classpath files into src control, no matter where they are located. Can you try and have those files removed from source control and generated for each developer locally.
Personally, I always do that when I first create the Eclipse workspace by creating my project from the pom file: File -> import -> Existing Maven Project and then I browse to the pom.xml file. My understanding is that this is (for many) the preferred way to create the java project in Eclipse.

what is the difference between maven-archetype-webapp and eclipse dynamic web project

why do I need to apply: mvn eclipse:eclipse command?
are they equivalent to application container/server?
Is there a file for which customizing is necessary besides web.xml?
when you create a web project using maven, like maven-archetype-webapp. It creates the folder structure as recommend by Maven for a webapp like shown here .
Now when you try to import these folders in Eclipse, it still would look like folders but eclipse cannot understand the nature of these folders. Eclipse relates folders and contents within them to an Eclipse dynamic web project only through its .project , .settings files
So in order for your maven project to be understood by Eclipse, you run the goal mvn eclipse:eclipse. After executing this goal, maven generates the .project, .settings files necessary for eclipse to understand the project as Web project.
This is however optional. You can still import the project as Maven projects within eclipse and continue to use them but you cant rely on Eclipse's features like clean/ build / build automatically.
Though I use eclipse, I dont rely on Eclipse's build feature. I have installed Maven eclipse plugin and that allows me to run maven goals and commands within Eclipse which is as good as running Eclipse's build feature. Hope this helps.

How to "add Maven nature" to existing netbeans project?

I know "adding Maven nature" is an Eclipse term.
Actually I want to add SOME dependencies from maven repository by editing pom.xml file. Is it possible? I want to remain a directory structure and other JAR tracking of a project intact.
The project is of jMonkey SDK.
in netbeans there are no natures. Either the project is a maven project (by having a pom.xml file in project directory) or it's not. No matter what type, projects are just opened.
if your project is both ant based project (having nbproject/project.xml file and build script) and contains pom.xml, then the ant project takes priority and will be opened as ant project. No way to mix then. to load as maven project you will have to delete ant project related files and restart the IDE.
add minimal pom.xml file
close project
re import it to netbeans as maven project
or create a new minimal maven project and delete source and resource directories and place your project stsructure and
configure pom.xml to match with your directory structure
by specifying resources & source directories in pom.xml

Mavenising an Eclipse Java project without the wizard

This is probably a basic question for you here but here goes:
I'm building a java project using Maven in eclipse at the moment. I have a pom.xml file which is working fine, but I need to be able to organise my source files into 'src/main/java' and resources into 'src/main/resources' etc. Any other maven projects I've looked at are structured like this and the build goes to success without picking up any source files, since it "skips non existent resourceDirectory src/main/resources" and the others.
I currently have a source folder 'src', and eclipse won't let me add more source folders with 'src' in the name.
Any guidance whatsoever would be greatly appreciated.
Try right-clicking on the project and selecting Maven->Update Project Configuration from the context menu. Then refresh the project. If your pom is close to right, that should represent your project in eclipse the way you want.
Why don't you just open your pom.xml file in eclipse? It can recognize it and will built its project files correspondingly
In eclipse right click over the project / Build Path / Configure Build Path / Source (tab)/ Add folder and select the source folder you want. If the folder you need doesn't exist under /src/main create it following the maven conventions.
after that I would recommend:
mvn eclipse:clean eclipse:eclipse

Categories