I use intellij IDEA 15.0.3 and it has a built-in version of maven. When I try to add a library (mysql-connector), maven can't seem to find it.
image
If you did not tell Intellij to download dependencies automatically, it will continue showing like that on the picture. There are possible ways to follow. You can build your project with mvn clean install or you can change the settings of intellij to download artifacts automatically or you can triger download by clicking the button on the maven menu of the intellij.
Related
I have to add/change some features in a Spring boot api which has a blueprint repository. I downloaded the branch from gitlab and opened the same in IntelliJ. But IntelliJ does not detect any framework. Even the basic spring imports are failing. Also I usually use Maven as build tool, but the project requires me to use Gradle, However I am not allowed to download gradle on their environment(even my local). Can anyone please point me in the right directions please.
First, try to build the project from the command prompt:
gradlew clean build
If this is building successfully you are good to use the project in IntelliJ as a normal Java project and add/edit code. If this is not working then check what's the issue and update the question.
To add framework support (in your case Gradle as you mentioned) right-click the project and choose Add Framework Support (mostly at the top of the menu) and choose Gradle.
Edit
After successful gradlew clean build, reimport the project in IntelliJ by selecting build.gradle file.
I have the newest IntelliJ, and the create Maven project button is gone. I also cant find it in any of the lists.
See the intellij menu
You can see the difference here, in IntelliJ's Getting Started with Maven page:
https://www.jetbrains.com/help/idea/2016.1/getting-started-with-maven.html
Anyone know how to get it back?
I want it because then you get the structure, and the pom.xml file automatically.
You need to install the Maven plugin.
Go to Plugins (in IntelliJ; press shift-shift, and search for "plugins"). In Plugins window, search for Maven and install the Maven Plugins.
You can create java project and later right click on your project -> add framework support -> choose maven.
I am learning building a Java project in Eclipse using Maven. I created a Java project HelloWorld from
“maven-archetype-quickstart” template in a folder D:/maven_projects. Then to convert the Maven project to support Eclipse IDE, I navigated into the project folder and issued the commands:
mvn eclipse:eclipse and mvn package .
Then I imported the project in Eclipse and did the necessary Eclipse configurations like setting the Maven local repository in Eclipse classpath. Now the project in D:/EclipseWorkspace folder. I ran the project successfully in Eclipse printing "helloworld".
Now if I want to go on develop the project and for that reason want to add new dependencies in pom.xml in Eclipse, then the new jars are not added in classpath when I run the project.
So my question is after importing a Maven project into Eclipse how can I add more and more dependencies in pom.xml, then build and run the project? What is the recommended and efficient way to do this?
I would recommend you don't use the m2eclipse command line tools (i.e. mvn eclipse:eclipse) and instead use the built-in Maven support, known as m2e.
Delete your project from Eclipse, then run mvn eclipse:clean on your project to remove the m2eclipse project data. Finally, with a modern version of Eclipse, just do "Import > Maven > Existing project into workspace..." and select your pom.xml.
M2e will automatically manage your dependencies and download them as required. It also supports Maven builds through a new "Run as Maven build..." interface. It's rather nifty.
1.Update project
Right Click on your project maven > update project
2.Build project
Right Click on your project again. run as > Maven build
If you have not created a “Run configuration” yet, it will open a new configuration with some auto filled values.
You can change the name. "Base directory" will be a auto filled value for you. Keep it as it is. Give maven command to ”Goals” fields.
i.e, “clean install” for building purpose
Click apply
Click run.
3.Run project on tomcat
Right Click on your project again. run as > Run-Configuration.
It will open Run-Configuration window for you.
Right Click on “Maven Build” from the right side column and Select “New”.
It will open a blank configuration for you.
Change the name as you want. For the base directory field you can choose values using 3 buttons(workspace,FileSystem,Variables). You can also copy and paste the auto generated value from previously created Run-configuration. Give the Goals as “tomcat:run”. Click apply. Click run.
If you want to get more clear idea with snapshots use the following link.
Build and Run Maven project in Eclipse
(I hope this answer will help someone come after the topic of the question)
Dependencies can be updated by using "Maven --> Update Project.." in Eclipse using m2e plugin, after pom.xml file modification.
Just install the m2e plugin for Eclipse. Then a new command in Eclipse's Import statement will be added called "Import existing maven projects".
answer 1
Right click on your project in eclipse
go to maven -> Update Project
answer 2
simply press Alt+F5
after updating your pom.xml. This will build your project again and download all jar files
Right Click on your project
Go to Maven>Update Project
Check the Force Update of Snapshots/Releases Checkbox
Click Ok
That's all. You can see progression of build in left below corner.
When you add dependency in pom.xml , do a maven clean , and then maven build , it will add the jars into you project.
You can search dependency artifacts at http://mvnrepository.com/
And if it doesn't add jars it should give you errors which will mean that it is not able to fetch the jar, that could be due to broken repository or connection problems.
Well sometimes if it is one or two jars, better download them and add to build path , but with a lot of dependencies use maven.
If you are getting this error :in cucumber Exception
Cucumber Exception: java.lang.ClassNotFoundException:
cucumber.io.ResourceLoader :
then add following jar file to your pom.xml
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.1.8</version>
</dependency>
Run the maven build once and should be gone
I checked out a maven project and imported to my Eclipse (Indigo) with maven integration via the m2eclipse plugin. I configured the project as a maven project. When I r click on my project and click Run As... I'm able to see all the maven configurations (maven build, maven clean, maven install etc.) The project icon has an m indicating that it's a maven project. When I r click an go to Maven I'm able to see
Add Dependency
Add Plugin
New Maven
Download Javadoc
Download Sources
Update Project
Disable Workspace Resolution
Disable Maven Nature
-I was told that I'd be able to see 'Update Dependencies' under the Maven menu but it seems to be missing. Is this to be expected given my Eclipse version or something? Or do I have to configure the project in some way to get 'Update Dependencies' to show up under the Maven menu?
Are you able to see the option "Convert to Maven Project" under the "Configure" menu?
This answer is based on m2e in Eclipse Helios, I haven't tried it in later Eclipse versions yet.
On the latest m2e version I installed today, I've found I need to go to Maven / Update Project... in the context menu, then select the options you want. (The Update Dependencies option seems to be fixed in the "on" position on mine.)
It may be that the current version can still be configured to show the menus as they used to be; I don't know. I say this because my old version was of a later date than the original post here, but still had the Update Deps and Update Project Conf options in the Maven menu.
I am in Eclipse Indigo and I have installed m2eclipse plugin. I saw in Eclipse Helios there is an option Maven in the right click menu, when I clicked on a Project, but this option is not present now.
I have installed Maven from both of the marketplace and also from adding site in Install new software option in Eclipse(Help->Install New Software).
What I am doing wrong.
This question was asked before in SO, but I tried the solution provided there.
Is this option is really not present? What I want is to enable Maven Dependency Management of a Dynamic Web Project of Eclipse.
You have to do a right click on the project, then choose Configure → Convert to Maven project
Right Click on the Project --> Configure --> Convert to Maven Project.
It will show Maven Related Options.
One way is to import the project as Maven project.
If you are trying to install in Eclipse older versions, use YOXOS Marketplace - by EclipseSource. Search for "Maven" in marketplace. You will get Maven Integration for Eclipse provided by Sonatype. Use that to install.
After installing m2eclipse plugin, go to Window -> Preferences. Check "Maven" is enlisted at the left panel list
this happened to me because I imported a parent folder as a project. so all my projects where sub directories of this parent folder and not a project them selves. after deleting them (only) from the workspace and re importing them as separate projects, maven worked fine.