Tips for adding a jar package to a MAVEN project

Source: Internet
Author: User
Tags inheritance naming convention unique id xmlns

Date: 2016-7-15


content: How to add jar packages quickly and easily in Maven-furnished projects;


Simple description:

Recently in the three frameworks of Java learning, it is a cool tool to see some instructors using MAVEN to decorate and manage projects in the video. The use of the 666 is really not good. Then take the time to learn some of MAVEN's knowledge. But in building a MAVEN project (you can build your own MAVEN project by referencing blog: http://blog.csdn.net/wu631464569/article/details/51901440) After that, add your own jar package to the MAVEN project's pom.xml. But in the process of adding a lot of problems are always unexpected. So in order to solve these problems thoroughly today, write a blog post here as a record of future use. Also provides a reference template for the small partner gate that needs to be used.


What issues are encountered during the addition of the jar package in the Add pom.xml configuration file:

1. The jar package you added does not have this version in the MAVEN image warehouse, so there will be an error message in the Pom.xml file. This is a very troublesome problem. Is there no other way to grams to solve such problems? With this question, I searched the internet for a bit, there are the following ways to solve the problem:


Here are some examples of issues that arise during the use of MAVEN, which can be referenced when one party encounters such a problem again later:


one, obviously in my designated maven this is the path of the existence of settings.xml, but always error could not read settings.xml, this is why?

Could not read settings.xml, assuming default values

Why is there such a problem? How to solve this problem. As for the settlement, some people describe it as follows:

1.settings.xml The format of the problem, (can not be compared to the control) the following is my settings.xml content, feel no problem.

<?xml version= "1.0" encoding= "UTF-8"?> <!--Licensed to the Apache software Foundation (ASF) under one or more C  Ontributor license agreements.  See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License");  You are not a use of this file except in compliance with the License.  Obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 unless required by applicable  or agreed to writing, software distributed under the License are distributed on a "as is" BASIS, without warranties OR  CONDITIONS of any KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License. -<!--| The configuration file for Maven.
 It can specified at levels: |  | 1. User level.    This settings.xml file provides configuration for a single user, |             and is normally provided in ${user.home}/.m2/settings.xml.
 |                 |
 Note:this location can is overridden with the CLI option: |                 |
 -s/path/to/user/settings.xml |  | 2. Global level.                 This settings.xml file provides configuration for all Maven |                 Users on a machine (assuming they ' re all using the same Maven | installation).                 It ' s normally provided in |
 ${maven.home}/conf/settings.xml.
 |                 |
 Note:this location can is overridden with the CLI option: |                 |
 -gs/path/to/global/settings.xml | | The sections in this sample file is intended to give you a running start at | Getting the most out of your Maven installation. Where appropriate, the default |
 VALUES (values used when the setting isn't specified) are provided.
 | |--> <settings xmlns= "http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi= "http://www.w3.org/2001/xmlschema-
        Instance  xsi:schemalocation= "http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd" > <!--localrepository |
   The path to the local repository maven would use to store artifacts.
   | |
Default: ${user.home}/.m2/repository <localRepository>/path/to/local/repo</localRepository>- <localRepository>E:/Java/Struts2+Spring+Hibernate/Maven/repo</localRepository> <!-- Interactivemode | This would determine whether Maven prompts when it needs input. If set to False, | Maven would use a sensible default value, perhaps based on some other setting, for |
   The parameter in question.
   | | Default:true <interactiveMode>true</interactiveMode> <!--offline |
   Determines whether MAVEN should attempt to connect to the network when executing a build. |
   This is a effect on artifact downloads, artifact deployment, and others.
   | | Default:false <offline>false</offline>-<!--plugingroups |
   This was a list of additional group identifiers that would be searched when resolving plugins by their prefix, i.e. | When invoking a command line like "Mvn prefix:goal". Maven would automatically add the group identifiers |
   "Org.apache.maven.plugins" and "Org.codehaus.mojo" if these is not already contained in the list. |--> <pluginGroups> <!--plugingroup |
    Specifies a further group identifier to use for plugin lookup. <pluginGroup>com.your.plugins</pluginGroup> </pluginGroups> <!--proxies |
   This is a list of proxies which can being used on the the network. | Unless otherwise specified (by system property or command-line switch), the first proxy |
   Specification in this list marked as active would be used. |--> <proxies> <!--proxy |
     Specification for one proxy, to is used in connecting to the network.
 |   <proxy> <id>optional</id> <active>true</active> <protocol>http&lt ;/protocol> <username>proxyuser</username> <password>proxypass</password> &lt ;host>proxy.host.net 

2. There may be a problem with the Repository warehouse. (The path is best not to have Chinese)

3, there are netizens to solve this: http://blog.csdn.net/hqocshheqing/article/details/47702049 feel quite a bit of truth.



second, the following problem occurs when adding spring's jar package dependency in Pom.xml.

Multiple annotations found at the:
	-Failure to transfer org.springframework:spring-core:jar:4.1.3.release From Http://repo1.maven.org/maven2 
	 is cached in the local repository, resolution is not being reattempted until the up Date interval of central have elapsed or updates are forced. Original error:could not 
	 transfer artifact Org.springframework:spring-core:jar:4.1.3.release from/to Central ( HTTP://REPO1.MAVEN.ORG/MAVEN2): No response received after 
	 60000

I'm messing around and I'm not compiling a bug.

The word before the local warehouse in my setting.xml is this:

<localRepository>E:/Java/Struts2+Spring+Hibernate/Maven/repo</localRepository>

I changed it to:

<localRepository>E:/Java/Struts2+Spring+Hibernate/Maven/repo/</localRepository>

This error is solved, it is estimated that their own path to write errors.

However, the above could not read settings.xml problem is still unresolved.


Or if the Spring-core jar package is missing from Maven's local repository, I add the existing jar package to the corresponding directory and it will be loaded automatically. So compile through.

C:\Users\Administrator\.m2\repository\org\springframework\spring-core\4.1.3.RELEASE\spring-core (not previously)

But in the directory: e:\java\struts2+spring+hibernate\maven\repo\org\springframework\spring-core\4.1.3. There's Spring-core-4.1.3.release-javadoc.jar under RELEASE.

I'll copy the Spring-core-4.1.3.release-javadoc.jar from this directory to C:\Users\Administrator\.m2\repository\org\springframework\. The problem is resolved in the Spring-core\ directory.













Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.