Vaadin 20 starter project with errors in pom.xml - maven

What I did:
I went to start.vaadin.com
I selected "Vaadin 20" and "Java 16"
I downloaded and extracted the project
When I open the project in IntelliJ IDEA, I get three errors in the pom.xml:
Line 19, definition of parent: Project 'org.springframework.boot:spring-boot-starter-parent:2.4.6' not found
Line 143, vaadin-maven-plugin for prepare-frontend build goal: Plugin 'com.vaadin:vaadin-maven-plugin:20.0.1' not found
Line 164, production profile with vaadin-maven-plugin: Plugin 'com.vaadin:vaadin-maven-plugin:20.0.1' not found
The Maven Central repository is configured in the pom.xml file as a repository and as a plugin repository. Using my browser I can find the vaadin-maven-plugin in version 20.0.1 in the repository: https://mvnrepository.com/artifact/com.vaadin/vaadin-maven-plugin/20.0.1
When I change the version of the vaadin-maven-plugin to 19.0.7 and the version of the spring-boot-starter-parent to 2.4.5, the errors disappear and the dependencies could be found.
I am not behind a proxy and I don't have a firewall running on my computer. I use Apache Maven 3.8.1 and AdoptOpenJDK 16.0.1.
Any ideas what I am missing?

If Maven has failed to load dependencies for whatever reason then you might need to run mvn -U for it to retry from the network instead of only the local cache

Sorry, the problem was related to IntelliJ IDEA. The fix was really easy:
Menu "File > Invalidate Caches", select "Clear file system cache and Local History" and "Clear downloaded shared indexes", click on "Invalidate and Restart".
Looks like some cache or index files of IntelliJ got corrupted. Opening the project after the restart took a little bit longer because IntelliJ needs to reindex everything, but the three errors in the pom.xml are gone.
Sorry, I totally forgot about the caching of IntelliJ…

Related

Importing to IntelliJ - Error package org.springframework.boot does not exist

Dear Stackoverflow Community, I have the following problem with my spring boot starter application. I imported the starter project as a new maven project into IntelliJ. But IntelliJ does not find the dependencies I specified in the pom.
Image of my Application Class:
If I try to run the project I get the following error message.
Image of the Error Message:
I already tried everything from re-installing IntelliJ to re-importing the project or redownloading the dependencies. I simply dont know why IntelliJ doesn´t find the dependencies.
My pom.xml looks as following
Image of my pom.xml:
The first time I tried to edit the pom.xml it said to me "this file does not belong to the project". Maybe this might be one reason.
Running the whole thing with 'mvn install' or 'mvn clean verify' works.
Try this and then build: mvn -U idea:idea
Had the same problem. I have tried everything: invalidating cache, deleting the whole .m2 folder, changing settings, reloding the project, nothing helped.
The solution for me was to delete the .iml files which are IntelliJ module files used for keeping module configuration. After reopening the project it worked.
The idea was not mine, I found the hint here: https://intellij-support.jetbrains.com/hc/en-us/community/posts/203365204--package-does-not-exist-error-despite-autocomplete-being-aware-of-them
Sometimes your workspace could get corrupted.
In my case, I tried to Reload the project and it worked
in my case changed JDK version in Maven importer from JDK 11 to my local JDK version 1.8
Here is how my IntelliJ settings for spring boot application looks like
Click open -> browse your workspace -> and select POM.xml file
Check this in your intelliJ settings
Do this too [Settings --> Maven --> Importing]
I just had the same issue. My solution was to remove all dependencies from the pom, reload via maven -> Reload All Maven Projects. Run mvn compile. Add dependencies back to the pom, maven -> Reload All Maven Projects. Run mvn compile.
Now the Intellij build works.
You need to change Maven's JDK for importing option from Project JDK to the Path variable for Java on your machine.
You can get to this by going to Settings -> Build, Execution, Deployment -> Build Tools -> Maven -> Importing. Scroll down to the bottom and look for JDK for importing:. Select from the list the path variable for JAVA.
For Windows users, JAVA_HOME should be an option in the drop-down list.
Follow these steps, your problem should be solved. You just need to add Spring-framework-starter-web and Spring-framework-starter-tester from your pom.xml file.
Got to generate(ALT+Insert)
Add dependencies
Search "springframwork"
Add...
Here is the link
In my case, adding the project as maven project helped .

Can't get IntelliJ to download Maven dependency

I'm trying to get Apache Log4j 2.9.0 into my IntelliJ Maven project, but am getting nowhere. This is the first time I've tried to use Maven with IntelliJ; I've been able to use it successfully with Eclipse in the past. (I'm using Windows 10 if it makes a difference.)
What I've tried:
1) In pom.xml, Alt+Insert -> Dependency, search for an artifact with log4j. It will find log4j 1.x, but not log4j-api or log4j-core which are needed for 2.x.
2) Downloaded log4j 2.9.0 from Apache. Their web site didn't tell me what to do with the file; after unzipping the download, I copied the top-level folder to .m2\repository. Retried searching for log4j, but it still couldn't find log4j 2.x stuff; tried various things like "Reimport all Maven projects", the Update button on the Settings page for Maven, Invalidate all caches and restart.... nothing has worked.
Edit: When I typed the above, I was sure there was a pom.xml file in my download. But I just double-checked and there wasn't. So I don't know whether any of the downloads on the Apache web page will work for Maven.
3) On the Settings page for Maven Repositories, tried "Test" on all the "Artifactory or Nexus Service URLs". The Test seemed to work fine.
4) On the Maven Settings page, changed Maven Home Directory from Bundled (Maven 3) to something inside Program Files (x86)\Jet Brains, which showed up on the drop-down menu. Didn't help.
I'm using IntelliJ Community Edition 2016.1.1, build #IC-145.597, Maven 3.0.5.
I must be missing a setting, but I can't figure out what. The documentation at https://www.jetbrains.com/help/idea/maven.html isn't helpful for solving this.

missing artifact org.elasticsearch:elasticsearch:jar:5.0.0-alpha1

Even though I can see the JAR file in Maven Dependencies and in .m2/repository directory, I still get this error.
missing artifact org.elasticsearch.elasticsearch
Do you have any idea where I am doing wrong?
I have met the same question.You can try the flowing steps:
1.make sure your network is well connected.
2.go to .m2/repository,delete all the files
3.restart your project and run maven install and maven update.
After running a build from the shell (mvn clean install, etc.) and making sure the problem is caused by Eclipse - there are a few options:
First, try Project --> Clean...
Right click on the project in the Project Explorer pane and then choose Maven --> Update Project...
Disable and then re-enable Dependency Management - right click Maven --> Disable Dependency Management and then Maven->Enable Dependency Management
Close the project and then reopen it.

Intellij maven imports have broken classpath

I'm using Intellij 13, I've been using Maven quite happily for awhile now to manage the JAR dependencies.
But the last few I've imported are causing a broken classpath issue, and they're not being installed to the repository.
I though it might be just the JSONPath library, but when I tried to install Selenium drivers it also happened with those libs. I checked the local repository and the directories exist, but the JARs haven't downloaded.
This only started happening recently, and a lot of other dependencies have been installed fine (but not since this issue started happening). I'm really not sure what might have caused it.
Does anyone know how to troubleshoot this? Or why the JARs aren't installing? And can I just trigger an update somehow from Intellij to try to reinstall them?
Quick Edit Here:
I tried installing the modules using Intellij's "add library" feature. It installed them fine, whereas before I was just updating them directly in the pom.xml and it was downloading them.
The library feature seems a little better because it automatically adds them to my output artefacts anyway, but it would be nice if it also updated the pom so I can use it outside of the intellij environment.
So I'm not sure why updating the pom.xml isn't working any more...
I've had this issue in IntelliJ IDEA 2017 Ultimate.
After changing dependency versions, the IDE was unable to fix the path on its own. I went to my ~/.m2 directory and deleted all of the dependencies for the problem jar and then executed the "ReImport All Maven Projects" action. When it was complete, the dependency issue was resolved.
I had this problem with the Community version of IntelliJ Community edition. I was able to solve the problem using this process:
Click "Help" menu
Click "Find Action" and type "Maven Settings."
Click "Maven Settings."
Click the arrow next to "Maven" on the left hand side, to see the submenu
Click "Importing"
Check "Import Maven Projects automatically" and click "OK."
This should pull in all of the Maven dependencies from the pom.xml file, without you needing to manually add the libraries.
I hope this helps.
I have encountered a problem like this.
I resolved it as follows:
Project Structure >> Modules >> your module has problem >> Dependencies
then double click the jar that have problem, go to "Configure Project Library",
and then click "+", i.e. I add dependency jar manually, otherwise, the dependency jar is red (i.e failed status) or have none.
It's not really an answer, but I moved some stuff around the POM's and it seems to be working. I've got a bad internet connection, and I found that it kept stalling trying to download some of the jar files, and Intellij didn't seem to time out when it did stall, I ended up having to restart it each time it stalled to get the JAR's to download.
But it's working okay now by just editing the pom files, which is more convenient for me than libraries.
In my case I was having this exact problem because I was trying to import a local jar-with-dependencies without classifier. To solve this I just needed to add <classifier>jar-with-dependencies</classifier> to the maven dependency, e.g.:
<dependency>
<groupId>com.my.group</groupId>
<artifactId>myartifact</artifactId>
<version>1.0</version>
<classifier>jar-with-dependencies</classifier>
</dependency>
Hope this helps someone.
There can be different root causes of this issue. For me problem was that I had a maven settings file with a different name. Problem resolved after I went to intellij maven settings and updated the maven settings file path and then after maven refreshed my projects.
I solved the probelm by deleting it in module dependencies, and then importing it again.

m2eclipse says "Missing artifact" but I can build from cmdline!

I'm trying to use this Sonatype Eclipse plugin for the first time to handle an existing (huge) software that I can build with maven form the command line.
I have configured the plugin to use my maven 2.2.1 installation instead of the built-in Maven 3.
In Eclipse I have 25 projects (loaded through the root pom.xml) and 4 of them have compilation errors; the maven console contains a lot of lines like this one:
Missing artifact commons-logging:commons-logging:jar:1.0.4:compile
I have all the jars in my repository and the M2_REPO classpath variable correctly defined. Why the plugin doesn't see all the jars?
The .classpath file of those projects simply references "MAVEN2_CLASSPATH_CONTAINER", there isn't a list of the jars.
The pom.xml in Eclipse shows an error on the first line for the missing jars but I can build from the command line!
Any idea? I need help! I will try to move to NetBeans if I don't solve this problem.
Thank you.
You may need to to tell Eclipse to force update:
Project -> Maven -> Update Maven Project
and then make sure you have selected:
Force Updates of Snapshots/Releases
this happens when mvn install copies some jar files into Maven repository and Eclipse had checked this repo BEFORE this jar has been copied there.
If Dependency management is enabled when the above problems occur in Eclipse you can Project > Maven > Disable Dependency Management and then \Project > Maven > Enable Dependency Management. This normally remove any dependency errors in the pom.xml.
Also do as #Nishant indicated in his answer above after the above steps to complete the projects dependencies.
right click on your project > Maven > Update Dependencies
then
right click on your project > Maven > Update Project configuration
Assuming you M2Eclipse plugin is installed correctly this should solve the issue. Also, check if there is an option right click project > Maven > Enable dependency Management select that.
Using Eclipse Kepler, the removing and re-adding of the maven nature fixed this same issue I was having. What this process actually did was modify the .settings/org.eclipse.m2e.core.prefs file, changing the line
resolveWorkspaceProjects=false
to
resolveWorkspaceProjects=true
So you could probably make this change manually if you had to.
Adding my 2c for future Googlers:
Whenever this problem shows up, I delete the corresponding folder from the m2 repository (on a mac it's on ~/.m2/repository) and build again from eclipse with clean install.
Works every single time.
Close eclipse IDE and open it again, this issue should be fixed.
Just to add yet another possible resolution, if you have a multi-project build with interdependencies, if you have a repository defined in a child project pom to resolve a specific dependency that only that project depends on and it is relying on a partent project for it's other resolutions it fails to see those dependencies in the child project (even though it works from the command line).
Move the repo definition to the parent pom.
The lack of jars in the build path suggests you haven't enabled Maven dependencies. Right-click on the project, select Maven, select "Enable Maven Dependency Management". This allows M2Eclipse to reference your POM.
I finally found a workaround. It is surely a bug in m2eclipse, however the problem disappeared when I added quartz-1.6.0.pom next to quartz-1.6.0.jar in .m2\repository\opensymphony\quartz\1.6.0\
The pom is not present at http://repo1.maven.org/maven2/opensymphony/quartz/1.6.0/ but you can extract it from quartz-1.6.0-bundle.jar linket at http://jira.opensymphony.com/browse/QUARTZ-482
It's a strange solution but it worked on the PCs of my collegues too.
None of the other suggestions worked, but the following steps worked for me (SpringSource Tool Suite 2.6.1):
Back up the contents of the local Maven repository
Delete the repository
Project > Maven > Update Dependencies
Replace anything not available in a public repository from the backup
If disabling and enabling project dependency management doesn't help (usualy it helps) you can modify .classpath file in your project and add a line:
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
After eclipse restart dependencies should be added.
I had this same problem happened to me. On the CLI clean install, then on eclipse delete the dependency, paste it again and that did the trick.
Remove all the artifacts except the jar in maven local repository
Late answer: In my case I had multiple profiles in settings.xml. Building worked since the correct profile was selected in the Maven Build run config, but the editors showed errors because the profile was not selected via Project -> Maven -> Select Maven Profiles ...

Resources