Tag Archives: maven

[maven-38382;- 39064; java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map

Open source software supply chain lighting plan, waiting for you>>>

The following exception occurred in today’s Maven build of notifyservice site

WARNING] FAILED org.eclipse.jetty.maven.plugin.JettyServer@3c64339f: java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
    at org.glassfish.jersey.server.ApplicationHandler.<init> (ApplicationHandler.java:331)
    at org.glassfish.jersey.servlet.WebComponent.<init> (WebComponent.java:390)
    at org.glassfish.jersey.servlet.ServletContainer.init (ServletContainer.java:172)
    at org.glassfish.jersey.servlet.ServletContainer.init (ServletContainer.java:364)
    at javax.servlet.GenericServlet.init (GenericServlet.java:244)
    at org.eclipse.jetty.servlet.ServletHolder.initServlet (ServletHolder.java:616)
    at org.eclipse.jetty.servlet.ServletHolder.initialize (ServletHolder.java:396)
    at org.eclipse.jetty.servlet.ServletHandler.initialize (ServletHandler.java:871)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext (ServletContextHandler.java:298)
    at org.eclipse.jetty.webapp.WebAppContext.startWebapp (WebAppContext.java:1349)
    at org.eclipse.jetty.maven.plugin.JettyWebAppContext.startWebapp (JettyWebAppContext.java:297)
    at org.eclipse.jetty.webapp.WebAppContext.startContext (WebAppContext.java:1342)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart (ContextHandler.java:741)
    at org.eclipse.jetty.webapp.WebAppContext.doStart (WebAppContext.java:505)
    at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart (JettyWebAppContext.java:366)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:132)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:114)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:61)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart (ContextHandlerCollection.java:163)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:132)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:114)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:61)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:132)
    at org.eclipse.jetty.server.Server.start (Server.java:387)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:114)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:61)
    at org.eclipse.jetty.server.Server.doStart (Server.java:354)
    at org.eclipse.jetty.maven.plugin.JettyServer.doStart (JettyServer.java:73)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:68)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty (AbstractJettyMojo.java:535)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute (AbstractJettyMojo.java:358)
    at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute (JettyRunMojo.java:167)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[INFO] Jetty server exiting.

This kind of error usually means that you have both jax-rs 1 and jax-rs 2 jars on the classpath. Jersey2 uses jax-rs 2 (javax.ws.rs-api-2.0.1. Jar), but if you still have jsr311-api.jar, it is jax-rs 1. There is a javax.ws.rs.core.application in each jar. But the jsr311 API application does not have getproperties() method (so nosuchmethoderror)

mvn d ependency:tree -Doutput=tree.txt The export dependencies are as follows:

It’s true that there are two versions of javax.ws.rs-api at the same time. After exclude, rebuild, OK

The problem of JUnit test report class not found in maven

Open source software supply chain lighting plan, waiting for you>>>

When you first contact maven, the path of Maven is not the same as that of normal eclipse projects. Java files are placed in Src/main/Java directory, and test files are placed in Src/test/Java directory. The normal test method is to use MVN test for unit test, but you are used to using eclipse. When you test directly in IDE, you will report exception, class not found exception

At the beginning, I thought it was the problem of the build path, because when I was watching maven, someone on the Internet said that they wanted to set the buildpath of eclipse, and then changed it. But sometimes it was good and sometimes it was bad. I felt that the problem was not here. If you think about it more carefully, since it’s class not found, go and look for the class file to see if the directory is correct. Once you look for it, you can find the reason. There is no such class at all. In other words, the java file is not compiled into a class file at all. In eclipse, it can help us compile automatically, but after we run the MVN clean command in maven, we will clean up the compiled class file. At this time, if we use Maven to test and run MVN test, Maven will help you compile again automatically, and the test can run normally. However, if it is directly in eclipse, eclipse will report an exception if it can’t find the compiled class file. The solution is to run the command MVN test to test. After the test is passed, as long as you don’t run MVN clean again, you can also pass the unit test directly in eclipse

The lessons learned this time: don’t rush to check the Internet for some problems. Think about why you report such abnormalities. Think about the deep reasons. Maybe the solution is very simple

Problems encountered in using Maven – lambda expressions are not supported at language level’5 ‘

Open source software supply chain lighting plan, waiting for you>>>

Problems encountered in using Maven – lambda expressions are not supported at language level’5 ‘

I encountered this problem in running Maven project today. So I follow the advice given by the system. The language level has been modified

Then the lambda expression didn’t report an error, and I was happy. Then run the code and the following error occurs

Maven Error: Failed to execute goal on project xxx: Could not resolve dependencies for project

Error Description:

Failed to execute goal on project xxx: Could not resolve dependencies for project com.jd.ka: xxx:war :0.0.1-SNAPSHOT: The following artifacts could not be resolved: com.jd.ka:ka-explore- service:jar :0.0.1-SNAPSHOT, com.jd.ka:ka-explore- rpc:jar :0.0.1-SNAPSHOT: Failure to find com.jd.ka:ka-explore- service:jar :0.0.1-SNAPSHOT in http://artifactory.jd.com/libs-snapshots-local was cached in the local repository, resolution will not be reattempted until the update interval of snapshots_ local has elapsed or updates are forced -> [ Help 1]

Solution:

1. First of all, I believe that since you have made such a mistake, your project should also have multiple modules. It’s like this:

2. Let me give you an example here, so the application is web and service

3. Both projects inherit the parent project

4. In the module, the web depends on the service. After the clean and install in the web, the local warehouse also has the dependency, but the install in the service will appear

Failed to execute goal on project …: Could not resolve dependencies for project …

In this way, I found that I didn’t clean and install the parent project, that is, the interface test project

5. summary: some subprojects under the parent project should run clean and install of the parent project before running clean and install for the first time

Failed to create webapp project with Maven in idea (without SRC and other file directory): received fatal Alert: Protocol_ Version solution

Geeks, please accept the hero post of 2021 Microsoft x Intel hacking contest>>>

Specific steps:

1. First, add a configuration to Maven Runtime: – dhttps. Protocols = tlsv1.2, as shown in the following figure

2. Create project or module

3. When selecting a webapp template, use the Maven below instead of the coco above

3. The rest is the normal flow of things, not to repeat

Created web project structure:


explain why :

Due to the insecurity of tlsv1.1 protocol and the PCI security standard, maven sonatype central warehouse no longer supports tlsv1.1 and the following protocol versions from June 18, 2018

For the original text, please refer to the official explanation of no longer supports tlsv1.1 and below

The JDK I use is 1.7. Although jdk1.7 supports TLS 1.2, it is disabled by default, so the received fatal Alert: protocol above will appear_ Version exception

The following table shows the default TLS protocol used by JDK in different versions of Oracle documents:

solutions:

scheme 1: upgrade JDK to 1.8

JDK1.8 TLS 1.2 is enabled by default, and this exception will not occur

PS: the price can be a bit high, especially for some old projects, which can not be upgraded just by upgrading

scheme 2: enable TLS 1.2 by adding – dhttps. Protocols = tlsv1.2 and configuring the Java runtime parameter

summary: if you are JDK 1.7, both schemes are OK (this article uses the second scheme). If you are 1.6 or below, it is recommended to upgrade JDK

Maven Error: No goals have been specified for this build [How to Solve]

Error:

Nogoalshavebeenspecifiedforthisbuild.Youmustspecifyavalidlifecyclephaseoragoalintheformat<plugin-prefix>:<goal>or<plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>.Availablelifecyclephasesare:validate,initialize,generate-sources,process-sources,generate-resources,process-resources,compile,process-classes,generate-test-sources,process-test-sources,generate-test-resources,process-test-resources,test-compile,process-test-classes,test,prepare-package,package,pre-integration-test,integration-test,post-integration-test,verify,install,deploy,pre-clean,clean,post-clean,pre-site,site,post-site,site-deploy.->[Help1]

Solution:

pom.xml file<build> tag followed by<defaultGoal>compile</defaultGoal> will do

Spring boot starter parent cannot be found when creating Maven project, and the parent node reports an error

Why can’t you grab tickets when you travel on holiday?Reveal the key technology of 12306 how to ensure the ticket is not oversold>>>

problem : after creating Maven project in idea and setting parent project, project ‘org. Springframework boot:spring-boot-starter-parent : x.x.x.release ‘not found

cause of problem : missing POM file in local warehouse

solution : Enter https://maven.aliyun.com/mvn/search , search for the missing POM file, and pay attention to select the missing version number, as shown in the figure (what I’m missing is org. Springframework boot:spring-boot-starter-parent :2.0.7.RELEASE)

Download it to the local computer and put it in the corresponding directory

In idea, right-click Maven — > Reimport to re import, to solve the problem

Maven: How to uses tomcat8 Maven plugin

After searching a bunch of articles on the Internet, we found no solution, only the plugin of tomcat7 Maven plugin, as follows:

<plugin>
  <groupId>org.apache.tomcat.maven</groupId>
  <artifactId>tomcat7-maven-plugin</artifactId>
  <version>2.2</version>
</plugin>

There is no plugin for tomcat8 Maven plugin. There is no such plugin in Maven’s central warehouse

https://repository.apache.org/content/repositories/snapshots/org/apache/tomcat/maven/

One was found in the MVN repository

Adding the above dependency to pom.xml either prompts that the dependency cannot be found or cannot be downloaded. After searching for a long time, we found a solution, which is to use & lt; in Maven; pluginRepositories> ,& lt; pluginRepositories> It is used to configure the plug-in address, because all functions of Maven are implemented by plug-ins, so you need to download the plug-in package from a specific address

Add the following to POM. XML

<pluginRepositories>   
	  <pluginRepository>   
		<id>alfresco-public</id>    
		<url>https://artifacts.alfresco.com/nexus/content/groups/public</url>   
	  </pluginRepository>    
	  <pluginRepository>   
		<id>alfresco-public-snapshots</id>    
		<url>https://artifacts.alfresco.com/nexus/content/groups/public-snapshots</url>    
		<snapshots>   
		  <enabled>true</enabled>    
		  <updatePolicy>daily</updatePolicy>   
		</snapshots>   
	  </pluginRepository>    
	  <pluginRepository>   
		<id>beardedgeeks-releases</id>    
		<url>http://beardedgeeks.googlecode.com/svn/repository/releases</url>   
	  </pluginRepository>   
  </pluginRepositories>

Add the tomcat8-maven-plugin dependency

<plugin>
          <groupId>org.apache.tomcat.maven</groupId>
          <artifactId>tomcat8-maven-plugin</artifactId>
          <version>3.0-r1655215</version>
          <configuration>
		<url>http://localhost:8080/manager/html</url>
		<server>tomcat</server>
	 </configuration>
        </plugin>

Then you can use tomcat8-maven-plugin plugin.

When you deploy for the first time, you can change the command to tomcat8:redeploy when you redeploy.

 

NoClassDefFoundError: Failed resolution of: Lorg/apache/http/conn/scheme/SchemeRegistry;

When the Android project is running on Android 9.0, it will flash back and report the following error

Java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/conn/scheme/SchemeRegistry;

terms of settlement:

Add the

<uses-library android:name="org.apache.http.legacy" android:required="false" />

Contribution by aizier River

idea Failed to clean project Failed to delete target

Failed to execute goal org.apache.maven. plugins:maven-clean-plugin :2.5:clean (default-clean) on project aaa: Failed to clean project: Failed to delete D:\IdeaProjects\aaa\target -> [ Help 1]

When packing through maven, the target file will be prompted to be occupied when cleaning

resolvent:

 
In the start search box, enter “resource monitor” to open the resource monitor, as shown in the following figure:

 

In this window, switch to the CPU tab, enter the file name (target) in the associated handle, and press enter to find the occupied process

Right click to end the process. ok