I have little issue with my Intellij Idea. When I change chode, for example just add annotation, or edit some function, and run my project (or run debug) these changes are missing. I must stop project and run mvn clean package
When I run / debug project again, these changes are reflected. I guess problem is Idea running project from target folder, but it is only my cogitation. Do you have ideas whats is wrong? In project I am using Tomcat 8.5, spring 5, and hibernate 5 if depends on it. Thanks
Check Before launch options in your Run/Debug Configuration. Make sure you have Build step there - that is the instruction for IDE to build your project before launching the Tomcat server and deploy the application.
If you do not use IDE's make you can add mvn clean package Maven goal there.
Related
I was using Maven to manage my project in Eclipse, but decided that Gradle looked like something that could end up benefiting me more. I'm trying to implement a CI/CD pipeline, but want to check certain thing (unit test success, and code coverage for example). After converting my project using
gradle eclipse
I find that I am no longer able to run JUnit test cases via the context menu
Right Click -> Run As... -> JUnit Test
With the following error
Class not found <package>.<class>
But when I run
gradle test
All of them pass, but don't give me any more information (which were run, which ones failed, which ones errored out).
By switching to a Gradle project, can all tasks only be run in the context of Gradle now? There are no errors reported in Eclipse, and building works fine. I have verified that the files are in the expected locations.
I was able to solve this doing the following steps.
Close the project in eclipse
Delete the project from the eclipse workspace (not from the file system)
Close eclipse
Open command line terminal
Run gradle cleanEclipse eclipse
Open eclipse
Import as a gradle project
At that point, everything was set up again.
This was happening to me as well. I was comparing Gradle to Maven, and I couldn't right mouse click on my Test.java file and Run as JUnit Test. My project had originally started as a Maven project, and I had converted it to Gradle. The problem was due to the old JUnit Run Configurations. All I did was go into Run Configurations and delete all the ones for JUnit. After I did this it started working. Hope this helps as the gradle eclipseClean eclipse didn't work for me.
You could have done just with single step "Import as a gradle project" in newer Eclipse IDE instance.
I'm transitioning from Eclipse to IntelliJ Idea and having some trouble getting my Maven Web project running as I'd like. In Eclipse, I ran it using mvn tomcat:run, which worked fine with JSP debugging. In IntelliJ, I created a run configuration to use this command, and it works, but JSP debugging doesn't work.
I tried to find info on getting JSP debugging to work on IntelliJ, and the only info I found involved setting up a Tomcat server in IntelliJ, not using Maven's tomcat with mvn tomcat:run. The problem is, I can't figure out how to do this without IntelliJ using it's own builder instead of building the project with Maven. I can add Maven goals like "mvn compile", but when I set it to deploy exploded war, and adds 'build myproject:war exploded artifact' to the build queue, which calls IntelliJ's builder.
IntelliJ's builder takes forever to build my project. I've never even let it finish. To be fair, the project is huge, but Maven builds to fairly quickly. Also, everyone in my company is using Maven to build it, so I need to use Maven as well.
Can anyone help me either get JSP debugging working using mvn tomcat:run, or on an Intellij managed Tomcat with the project built by Maven?
In IntelliJ you can easily debug a "remote" tomcat instance (one running in a different JVM than IntelliJ):
Run -> Edit Configuration -> "+" -> Tomcat Server -> Remote
That will create a new run configuration. Look at the information on the "Startup/Connection" tab for the parameters to add to the tomcat JVM. Mine are:
-Xdebug -Xrunjdwp:transport=dt_socket,address=57813,suspend=n,server=y
Finally, start tomcat by launching the required maven command. Then run the above run configuration (click debug button).
I have two maven projects and both are working fine independently. I am able to create a jar file and run it from console as well as from eclipse.
I copied over some classes from the second project into the first and made a few changes so that it runs as a single project with features from both.
I have two pom files, so I combined them into a single pom file.
The thing is that I am able to run it from eclipse fine and able to get the output I was hoping for.
But I am not able to run it after executing the jar file created from "mvn package".
I am using shade maven plugin.
If I use maven build.. with clean install as goal, it again showing errors.
My question is this, why this discrepancy?
We would need more information to correctly diagnose the issue. One thing to look at is to ensure that any changes to dependencies which are projects in Eclipse have been installed as a command line build will only look in your repo, not at your Eclipse project.
This may happen when you have a dependency which exists as an open project in your eclipse workspace.
Try closing every project except the one where you're having this problem. Does it still compile in eclipse then?
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)
I have a that uses maven... and I want to put it in my working environment with eclipse(Galileo)... the project is in a svn server, and I can create check out the project and everything looks OK. I even can run the unit test and everything is working there.
However, now that everything is there I wanted to work in the code, and oh surprise there are no packages in my project... I mean all the source code is in the src folder and browsing through it i can see all my files, ut if I open the files from there, the files are opened as text files with no coloring, but worst no help at all about errors in compilation.
I don't know what im I doing wrong now, because I had the same project in other machine and it was working well.
So here is what I did, please let me know if you notice if I did something wrong, miss any steps or anything that can help me:
In the SVN Repository (Using subclipse 1.6.10) I added my SVN Repository
Browsed to the folder where I have the pom file
Right Click> Check out as a Maven project...(Using m2eclipse 0.10.020100209)
Used the default options and finish.
The projects were created with no problem. I said projects because this maven project has modules, and each module became a project in eclipse.
Back in the java perspective, Right click in the project, Run as > maven test(Using JWebUnitTest, because I am testing a servlet)
BUILD SUCCESS!!
But as I said there is not packages so I can't really develop in this environment.
Any help??
Thanks!
When performing a svn checkout as maven project, m2eclipse writes what it does in a console window, accessible using the "console" panel, where there is a drop-down list of all available consoles. What does this console tells ?
Besides, if you can perform a maven test, you can also, in the maven menu (of your contextual menu) do a "update project configuration" which should do the same thing and configure eclipse for your project.
As a last test, is there a maven icon over your project ?
Have you tested your setup on command line with Maven ? Does a mvn package work without errors ? The location for the sources in Maven is src/main/java + Package name. Have you opened the project as a Maven project?
Thanks for your help, however I noticed that eclipse itself was behaving weird when I try to create a package there and I didn't have the option.
So I found out that for some reason that eclipse installation wasn't giving me any of the Java basic options.
So I download a new eclipse installation.. and I repeat the whole process and now is working...
No clue what was the problem with this eclipse because I was using it for other projects and I don't know when I lost the basic functionalities!
Thanks anyway!