Resource file is missing with maven - java

I'm working on a GWT project with maven. Since I want to keep my workspace organized I'm putting all my resources on src/main/resources instead of src/main/java. The problem is that eclipse gives an compile error saying that the file is missing. On the other hand if I insist in proceding the project compiles and works properly (it does find supposedly missing resources). How can I correct this?
Thank you.

Remove the project from Eclipse and afterwards delete the Eclipse specific files (.settings, .classpath, .project) and import the project from scratch. The problem is based on the thing that the life-cycle is started from scratch in case of importing it. If a project is already important some parts seemed to be not executed.

Related

Intellij IDEA editing gradle project file vs project settings

It took a few tries to figure out that the way gradle integration works, is by Intellij scanning the gradle project file, and then creating the project settings from it. What was confusing me, and is still confusing me, is how the IDE fails to pick up certain things. It also seems to spontaneously change things like the src directory. I end up having to go in to the project settings, and fix things like marking the appropriate directory as a source directory, and re-adding the excluded source directories. It seems to ignore the exclude statement from the gradle file.
Am I going about this the right way? Why does my project build fine from the command line using the gradlew command, but often does not inside the IDE? Is it normal having to "fix" various project settings? Are these bugs or incomplete features in Intellij?

Classes packages don't include src.main.java, however it is there and eclipse complains about it

I've downloaded an open source library which has the source laid out like this:
src.main.java.company.name
However the source files always have their package name omitting the src.main.java part, for example:
package company.name.DataAccessControler
and eclipse complains about it. Of course I could rename each file, but there are dozens of files and I'm pretty sure I'm missing something.
The pom.xml doesn't have any references to src.main.java.
What could be the cause of it, and how to fix it? I believe it might related to eclipse.
There is nothing wrong with your library... Since this is a Maven project, /src/main/java is the default directory layout :
https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
You shouldn't touch the build path since this is managed by the Maven Plugin in Eclipse.
Try a right-click - Maven - Update.

Unable to solve import classes in maven project

I am developing a maven project using IntelliJ-14. The other day everything was correct without any problem but today when I got in the project some of my imports are not working. When I compile it is everything ok and I can run the project but autocomplete does not work and some classes appear red.
I've tried to go File-> Settings-> Maven-> Importin-> Import Maven Projects Automatically check. Already imported the project again and nothing. In external libraries classes exist.
An example of my code is here.
What else can I do to solve this?
Please help
Right click on the project-->Maven--->UpadateProject.
This may help you.
Some possible solutions since we can't tell what is actually wrong:
Delete your .m2 folder and do a reload maven project
Go invalidate "caches and restart" (File - Invalidate caches /
Restart)
If you work with other people see if they have committed something that breaks the maven build. Some times the version of jars that you have in your local maven repo (.m2 folder in your %USER_HOME% folder) is different than the one that they other devs using
Do "Reimport all maven projects"
I experienced the same problem. Before it occured, I created a package structure from within IDEA, for example "de.ulli.myPackage". Of course I expected to get the directory structure "de/ulli/myPackage". I don't know why, but actually there was a single directory named "de.ulli.myPackage" (OS Windows 7 64 Bit). Maven was able to build the project, and I even could generate classes via IDEA. But autocomplete didn't work and the classes within the package appeared red in other sources. After reparing the directory structure, everything was fine.

How to import a Jar into Eclipse

I have been making something in eclipse until just recently I had some technical issues causing my hard drive to be completely destroyed and I lost everything except a jar file.
I wish to start working on it again but am not sure what to do since I have no source file just the jar. I tried decompiling and importing except it made a mess of my code and will take forever to clean it up. Hopefully I did something wrong and there is a much easier way to do this.
If you don't need the sources of the JAR you can make a dependency to it within eclipse (right click on project -> Build Path -> Dependencies).
Or if you use a build tool (maven, gradle, etc.) put the jar to your local/remote repository and put it as dependency to your build file.
Otherwise decompile the JAR for e.g. with Java Decompiler and put the java files to your eclipse project.

Eclipse IDE behaves weirdly

I am getting a class not found exception for my Login Controller when I try to login to my application(It is a spring MVC Application). Before running the maven clean command the Application was running perfectly, I used maven clean and then again done a build using maven package command, suddenly it stopped working. I tried restarting the TomCat, re-deployed the application on TomCat, restarted the Eclipse IDE but nothing has worked so far.
Why this happens and what is the possible solution to this ??
Are you trying to run your project under Eclipse?
And does it generate source files?
If these are both true, you probably need to update the project config (select project or pom, right-click, Maven..Update..Project Configuration and Maven..Update..Project Dependencies).
The problem is that when Maven does a clean, it gets rid of the generated directories, which Eclipse observes and removes from your Build Path. But then when Maven rebuilds the directories, Eclipse doesn't notice it - you have to give it a hint.
Check your project for build errors and build path errors.
Make sure you've defined an M2_REPO classpath variable in Eclipse (Preferences - Java - Build Path - Classpath Variables).
If you're using the m2eclipe plugin, right-click your project and click on Maven - Update project configuration. That will configure an Eclipse build path for your project based on your pom dependencies.
If you're not using m2eclipse, execute mvn eclipse:clean eclipse:eclipse in your project folder. Then refresh your project in Eclipse.
What you haven't said is that you've checked and the missing class is in fact present.
A quick way to check is in the code editor SHIFT+CTRL+T and type the name of the missing class. Eclipse should not only show you the class if it exists, on highlighting the class, Eclipse should tell you which jar it is in.
Based on the info you have provided, I would say some dependecy in your POM has been removed by mistake or you need a newer version of some jar. If you find the class is not present, then you can figure out which jar you need by googling something like Maven 2 MyMissingClass jar that usually works for me.
Delete the .metadata folder in your eclipse workspace and then again open the workspace and import the required project.
This will solve your problem.
In .metadata folder it maintains the temporary copy of the project.
what worked in my case was simply removing the project from work space and importing it back again.
But I still don't know why it worked Vs why other things mentioned did not work (I tried updating dependencies in fact I removed all the dependencies from pom.xml and added everything again)

Categories