Show Logback error when I run Simple Spring Boot project - spring

I follow this tutorial to create spring boot project, when I run the project, it shows an error. Please help me to fix it.
my pom.xml

You mentioned that it worked with gradle but not Maven.
One possible solution is to delete your local maven repository to force it to redownload the dependencies:
Go to your home folder and remove the folder ~/.m2/repository.
Then, try rebuilding your project with maven : mvn clean install

I try to update Java and Maven,but it also do not work,and then I change Maven to Gradle,the application can run! Maybe Maven has problem.

Related

Intellij MavenWrapperDownloader.java: Can not resolve symbol error

Setup:
Intellij IDEA community edition 2020.2
Spring Bott starter parent: 2.3.5
Java 11
WRAPPER_VERSION: 0.5.6
mvn 2
Hi,
I googled a lot e.g. here but I just can't fix it.
I created a new mvn spring project with Intellij. When I commit the project I get errors detected by code analyses in class: MavenWrapperDownloader.java.
e.g. It reports:
Cannot resolve symbol String
I tried:
invalidate caches and restart
delete .idea folder and reimport
checked sdk setup
mvn reimport
mvn clean and then rebuild (while the build is always successful)
I'm pretty new to maven. I guess the scope of the mvn package might be wrong because the build process works as expected.
UPDATE:
I reinstallt my openjdk11. No success. Then I found out that my .mvn/wrapper dir is not set as source root. I know that was never the case in my other projects. As a trial I've set my .mvn folder as source root and now the MavenWrapperDownloader.java file is recognized as a java class and the compiler interprets the symbols. But now there is another error. It says I have to define a package name for that class because the class does not have one per default. It is pretty strange to me. I also tried to use another spring boot starter version but nothing changed
When I execute Analyze->inspect code I get the following:
I had the same problem and File -> Invalidate Caches/Restart fixed it - at least for now.
IntelliJ Ultimate 2020.3
Spring Boot Starter Parent 2.4.2
Java 15
Maven 4.0.0
Maven Wrapper 0.5.6
The easiest solution is to generate your project again with Spring Starter.
After you set up everything you need at pom file -> Generate -> Download it.
Open with your IDE and copy-paste all code sources which you have already written.

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 .

Apache log4j 1.2.17 missing artifact error on pom.xml maven

I added the apache log4j 1.2.17 dependency in my pom.xml maven project. After saving the changes I have a lot of errors which are mostly "missing artifacts error". What should I do to fix this error?
This is the dependency I used from the maven repository
http://mvnrepository.com/artifact/log4j/log4j/1.2.17
I want to use Log4j as my logging framework for my selenium testing
Update your maven project by right click on it and choose options MAVEN>UPDATE PROJECT. It would resolve your problem.
If still you are getting same problem then use mvn eclipse:clean eclipse:eclipse to regenerate the eclipse project files -- hope that sorts you.

Spring STS MVC Project - Unable to Get Rid of Error

I have the newest STS build and have installed on Window 8.1. Following tutorials, I get a pom.xml error. Following any and all suggestions, including re-installing the STS does not fix it.
it is a maven configuration problem, try :
Right click on the project > run > maven build ...> goal : eclipse:clean
and then update the project
if the error is not fixed , then may be you have some corrupted dependencies
delete the folder .m2 under C:\Users\<the current user>\.m2 and update the project again, maven will load the missing jars 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