Issue
See the attached snapshots. I cloned this project and having issues working with this project in vs code:
https://github.com/javalite/jar-explorer
- Sometimes, the Maven tab or sub-view under the Explorer View is hidden. I did something that enable to section to show but I don't remember how. How I can show this Maven View if it is hidden?
- The project was built successfully using the command line
mvn clean install
, however, the vs code problem view was showing strange errors. I then notice the the POM.xml file didn't have this line at the top:
<?xml version="1.0" encoding="UTF-8"?>
Following is a sample of the errors I saw:
CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-compiler-plugin:jar:3.1: ArtifactResolutionException: org.apache.maven.plugins:maven-compiler-plugin:pom:3.1 failed to transfer from https://artifactory.xxx.dev/artifactory/clo-maven-dev during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.plugins:maven-compiler-plugin:pom:3.1 from/to central (https://artifactory.xxx.dev/artifactory/clo-maven-dev): Access denied to https://artifactory.xxx.dev/artifactory/clo-maven-dev/org/apache/maven/plugins/maven-compiler-plugin/3.1/maven-compiler-plugin-3.1.pom. Error code 403,
Failed to read artifact descriptor for junit:junit:jar:4.13.1
...
...
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: junit:junit:pom:4.13.1 failed to transfer from https://artifactory.xxx.dev/artifactory/clo-maven-dev during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact junit:junit:pom:4.13.1 from/to central (https://artifactory.xxx.dev/artifactory/clo-maven-dev): Access denied to https://artifactory.xxx.dev/artifactory/clo-maven-dev/junit/junit/4.13.1/junit-4.13.1.pom. Error code 401,
MD :mvn --quiet clean -f "c:\Projects\jar-explorer-master\pom.xml" && mvn --quiet org.apache.maven.plugins:maven-dependency-plugin:3.0.2:tree -f "c:\Projects\jar-explorer-master\pom.xml" -DoutputFile="c:\Projects\jar-explorer-master\target\dependencies.txt" -DoutputType=dot -DappendOutput=true
STDOUT : [ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project jarexplorer: Execution default-clean of goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean failed: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to collect dependencies at org.apache.maven.plugins:maven-clean-plugin:jar:2.5 -> org.codehaus.plexus:plexus-utils:jar:3.0: Failed to read artifact descriptor for org.codehaus.plexus:plexus-utils:jar:3.0: Could not transfer artifact org.codehaus.plexus:plexus-utils:pom:3.0 from/to central (https://artifactory.xxx.dev/artifactory/clo-maven-dev): authentication failed for https://artifactory.xxx.dev/artifactory/clo-maven-dev/org/codehaus/plexus/plexus-utils/3.0/plexus-utils-3.0.pom, status: 401 Unauthorized -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
I then added the this line to POM.xml:
<?xml version="1.0" encoding="UTF-8"?>
... and opened the project using Eclipse, and execute the Maven Update Project, and the errors disappeared. I think there was some issue with authentication due to proxy issues. Now, I see only about 100 warnings, and I am able to build using vs code.
I also noticed that the following file was added under .settings
folder when I executed Update from Eclipse:
org.eclipse.jdt.core.prefs
How I can add the above file org.eclipse.jdt.core.prefs
using vs code?
How I can resolve the following warnings using vs code:
Build path specifies execution environment JavaSE-1.7. There are no JREs installed in the workspace that are strictly compatible with this environment.
The compiler compliance specified is 1.7 but a JRE 1.8 is used
Solution
Following is a summary of the steps to resolve such problems:
Set up a proxy in VS Code to allow access to the needed URLs defined in
<user-home>\.m2\settings.xml
if you are behind a VPN. Or try to do the same from a personal computer to avoid using VPN to verify the root cause of your problems. Mind you, there could be a dependency chain, and one of the elements could not be accessed for some reason which will cause such errors. You need to understand the dependency chain and make sure you can access each dependency along the chain.Use
mvn clean install -U
to force the downloading again of all dependencies.Clean Java Project and Reload will solve specific problems.
For some reason, Maven View will never show by default. It would help if you gave it a kick by using
Ctrl-Shift-P
and attempting to run any Maven Command, then theMaven View
will pop out magically.Open the various output logs from the
output
tab and try to spot any errors. Open the different logs one by one and try to resolve the errors if found.Set up the correct default JRE/runtime/JDK needed for the project, in addition to JAVA_HOME version JDK 17+ needed by VS Code.
Try running
mvn eclipse:clean
and theneclipse:eclipse
to delete and regenerate Eclipse files.When the terminal is opened in VS Code, it would help to set the
JAVA_HOME
andPATH
environment variables with the correct JDK.
Answered By - tarekahf
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.