Tag Archives: maven

[Solved] Maven project startup error {datasource-1} init error

Problem: the project downloaded from SVN reports an error: {datasource-1} init error} oracle jdbc. OracleDriver

Reason: in the POM corresponding to the project The configuration corresponding to orcal database connection is not introduced in the XML file


After adding configuration, restart the project and solve the problem

Maven: idea cannot download the source code Issue [How to Solve]

Download the source code sources by clicking into the decompiled code file of idea.

The idea prompts an error and cannot download the source code.


mvn dependency:resolve is to resolve all dependencies of the project. Finally, it prints out the details of the resolved dependencies. Specify the optional parameter classifier = sources to try to analyze and download the corresponding dependent source code. Open teminal, execute it using the local maven, and then download it.

1 mvn dependency:resolve -Dclassifier=sources

Later, I encountered the problem that idea could not download the source code.

First confirm the file | settings | build, execution, deployment > Maven settings, Maven version is 3.8.3, configuration file is also 3.8.3, and local Maven warehouse also has settings.

Click to download the source code again, and you still can’t download it.

First, check whether the local Maven warehouse has downloaded the source code, and find a file about slf4j-api-1.7.21-sources.jar.lastupdated. This file is a record file of Maven’s failure in trying to download the slf4j API source code.

Open the file with Notepad + +. According to the contents, it seems that the failure to download is closely related to the Maven default HTTP blocker.

1 #NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
2 #Sun Nov 21 16:52:48 CST 2021
3 http\:// not transfer artifact org.slf4j\:slf4j-api\:jar\:sources\:1.7.21 from/to maven-default-http-blocker (http\://\: Blocked mirror for repositories\: [nexus-aliyun (http\://maven.aliyun.com/nexus/content/groups/public, default, releases)]
4 @default-maven-default-http-blocker-http\://

Check the setting.xml file, find the following related configurations, and comment out the Maven default HTTP blocker image, which prevents you from finding dependencies in Alibaba’s image library. At that time, I didn’t know what the problem was to solve. I set it up and commented it out first.

After saving, restart idea, and then you can download it. The problem is solved.

The source code files are also downloaded from the local repository.

[Solved] Mac install maven Error: zsh: command not found: MVN

After installing the java development environment in Apple Mac system, you want to execute Maven related commands on the command line

The problem Zsh: command not found: MVN is found. The first reaction is that the environment variable is not configured.

Configure environment variables

vim ~/.bash_ profile

export PATH=$PATH:~/maven/bin

source .bash_ profile

Verify that the configuration is in effect

mvn -v

Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739)
Maven home: /Users/codeboyzhou/maven
Java version: 1.8.0_312, vendor: Temurin, runtime: /Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"

You can see that it is indeed effective in the command line, and then when you open the terminal in IDEA and continue to execute other Maven commands, the problem is reported again zsh: command not found: mvn, what’s the matter?

Guess is because the new version of Mac system uses the default zsh, and .bash_profileis the Linux system bashenvironment variables configuration, try to modify the configuration file mv .bash_profile .zshrc, and perform once again source .zshrcmake the configuration take effect, the problem is solved. Restart IDEA and the corresponding terminal window to confirm that the problem has indeed been resolved.

Other online article that is zshnot automatically loaded when you start .bash_profilecaused, can be .zshrcadded to the last line of the file source .bash_profileit automatically take effect each time the terminal starts, this method is feasible. But because my system itself does not have .zshrcthis document, other configuration information does not exist, so I use the above method directly with the environment variable to .zshrcthe next file is able to quickly solve the problem, compared to operating steps and also more concise, Which method to use can be determined according to personal preference or specific circumstances.

Start Maven project in idea with jetty and report error caused by: java.lang.classnotfoundexception: org.apache.jasper.runtime.jspapplicationcontextimpl

Start the Maven project in idea with jetty and report this error. I use the default port 8080,

Caused by: java.lang.ClassNotFoundException: org.apache.jasper.runtime.JspApplicationContextImpl

Solution: 1. Change the port (I can start it by changing it to 8083). 2. Kill the occupied 8080 port and restart it

Maven Error: Failed to read artifact descriptor for xxx:jar and missing artifact maven dependency

When executing Maven’s install command in MyEclipse or adding new dependencies to pom.xml in Maven project, it reports “Failed to read artifact descriptor for xxx:jar” or ” missing artifact maven dependency” error. This may be due to a file error during the download process.
Solution: Remove the relevant jar package from the local maven library, then right-click the project, Maven4MyEclipse->Update Project, in the pop-up dialog box, select “Force Update Of Snapshots/Releases”.
Then click “OK”. This will re-download the jar package.

Different Eclipse versions of the project right-click Maven only will have different submenus:
Mine is shown below:

Then click “OK” and you’re done ……..
There are also several other ways provided …. (personal attempts did not work)
There are a few other options apart from Project->Clean, some of which are more along the lines of turning it off and on again.

Try right-clicking on the project and selecting Maven->Update Project Configuration.
Disable then re-enable dependency management (right-click Maven->Disable Dependency Management then Maven->Enable Dependency Management
Close the project and reopen it.
Check that your Maven settings are configured correctly. If you are behind a proxy you’ll need toconfigure the proxy settings in the global or user settings.
Check you’re using the Maven installation you expect. By default m2eclipse uses the embedder, if you have a separate installation you may want to configure m2eclipse to use the external installation so that CLI and Eclipse builds are consistent. This also ensures you’re configured to connect through any proxy as above.



Using idea and maven, there is an error: (4, 21) Java: there is no problem with the package javax.servlet

Problem description

Baidu’s many solutions are hard to make, too desperate. (fall)

You must find out the error information and your own use scenario to search, so as to find the correct solution

For example, I use Maven to create a normal Java Web project. Manually added webapp items.

As shown in the error message, it is really the problem that the package javax. Servlet does not exist. But all my bags came in, and there was no error, as shown in the figure below

Then I played with Maven’s clean and compile and idea’s cache clearing, which were useless. Of course, it’s not what other blogs say about setting environment variables and manually copying the package to Tomcat.


The problem is indeed the lack of servlet package, but it is not in the compiled file. The following figure shows the directory structure that should be generated normally

If the idea is the publishing method of the set Project Name: War expanded , the war package will be generated in the target folder

If there is no javax.servlet in the Lib directory of the war package, check it as follows:

1、< packaging> war set packaging method (jar package by default)

2. Manually added webapp projects have such problems

Summary: pay attention to whether there are missing packages in the compiled file. The problem must be found with the use scenario.

Using Maven helper to resolve Maven plug-in conflicts

1. What is dependency conflict

Maven is an easy-to-use dependency management tool, but the best thing is not perfect. Maven’s dependency mechanism will lead to jar package conflict. For example, now in your project, you use two jar packages, a and B. Now a needs to rely on another jar package C, and B also needs to rely on C. However, a depends on version 1.0 of C and B depends on version 2.0 of C. At this time, Maven will download both 1.0 C and 2.0 C to your project, so that there are different versions of C in your project. At this time, Maven will decide which version of jar package to use according to the principle of shortest dependency path first, while another useless jar package is not used, which is the so-called dependency conflict.

Most of the time, dependency conflicts may not cause any exceptions to the system, because Maven always selects a jar package to use. However, it is not ruled out that under certain specific conditions, there will be exceptions like unable to find classes. Therefore, as long as there are dependency conflicts, in my opinion, it is best to solve them and do not leave hidden dangers to the system.

2. Solution

The method to solve dependency conflicts is to use the tag provided by Maven. The tag needs to be placed inside the tag, as follows:


log4j core itself depends on log4j API , but because some other modules also depend on log4j API , and the two log4j API versions are different, we use tags to exclude log4j core dependent log4j API , In this way, Maven will not download the log4j API that log4j core depends on, which ensures that there is only one version of log4j API in our project.

3、Maven Helper

See here, you may have a question. How can I know which dependent jar packages in my project conflict?Maven helper, a plug-in of intelij idea, helps us solve this problem. I won’t talk about the installation method of plug-ins. Since you know maven, I believe you will also install plug-ins.

After the plug-in is installed, we open the pom.xml file, and a dependency analyzer option will be added at the bottom

Click this option

Find the conflict, right-click and select exclude to exclude the jar package of the conflicting version.

4. Tips

In addition to using Maven helper to view dependency conflicts, you can also use the method provided by idea – Maven dependency structure diagram. Open Maven window, select dependencies, and then click the icon (show dependencies) or use the shortcut key (Ctrl + Alt + Shift + U) to open Maven dependency structure diagram

In the figure, we can see some red solid lines. These red solid lines are dependency conflicts, and blue solid lines are normal dependencies.

Original address: https://segmentfault.com/a/1190000017542396

Maven Project Error running ‘ [org.apache.maven.plugins:maven-archetype-plugin:RELEASE:generate]’: Cannot start process, the working directory ‘AppData\Local\Temp\archetypetmp’ does not exist

Just a few days ago, when I transferred from myesclipse to idea, created a maven project with webapp framework package and tried to run it, such an error will appear

After tossing for half a day, it is found that this problem will not occur as long as the framework package is not selected when the project is created. After the project is created, right-click the add framework of the project to add the framework package, which can avoid errors.

Maven Package Error: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project Mybatis: There are test failures.

MVN compile   There is no problem. The following error is reported during MVN package:


There are two ways to package and skip tests

First, the command line:
MVN clean package – dmaven. Test. Skip = true

Second, write POM file: