精华内容
下载资源
问答
  • Maven配置源代码和资源目录

    千次阅读 2017-06-23 11:12:11
    Maven配置源代码和资源目录

    1、配置单个源代码和资源目录

    <build>
    	<!--默认源代码目录 -->
    	<sourceDirectory>src</sourceDirectory>
    	<outputDirectory>${project.build.directory}/classes</outputDirectory> <!-- ${project.build.directory}就是我们通常看到的target目录 -->
    	<!--默认测试源代码目录 -->
    	<testSourceDirectory>test </testSourceDirectory>
    	<testOutputDirectory>${project.build.directory}/test-classes
    	</testOutputDirectory>
    	<!--默认资源目录 -->
    	<resources>
    		<resource>
    			<directory>src</directory>
    			<excludes>
    				<exclude>**/*.java</exclude>
    			</excludes>
    		</resource>
    	</resources>
    	<!--默认测试资源目录 -->
    	<testResources>
    		<testResource>
    			<directory>test</directory>
    			<excludes>
    				<exclude>**/*.java</exclude>
    			</excludes>
    		</testResource>
    	</testResources>
    </build>


    2、配置多个源代码目录

      以配置源代码路径 src/junit/java 和 src/junit/resources 为例子:
         <build>
               <pluginManagement>
                    <plugins>
                         <plugin>
                              <groupId>org.eclipse.m2e</groupId>
                              <artifactId>lifecycle-mapping</artifactId>
                              <version>1.0.0</version>
                              <configuration>
                                   <lifecycleMappingMetadata>
                                        <pluginExecutions>
                                             <pluginExecution>
                                                  <pluginExecutionFilter>
                                                       <groupId>org.codehaus.mojo</groupId>
                                                       <artifactId>build-helper-maven-plugin</artifactId>
                                                       <versionRange>[1.0,)</versionRange>
                                                       <goals>
                                                            <goal>add-source</goal>
                                                       </goals>
                                                  </pluginExecutionFilter>
                                                  <action>
                                                       <ignore/>
                                                  </action>
                                             </pluginExecution>
                                        </pluginExecutions>
                                   </lifecycleMappingMetadata>
                              </configuration>
                         </plugin>
                    </plugins>
               </pluginManagement>
               <plugins>
                    <!-- 指定多个源代码目录、多个资源文件目录 -->
                    <plugin>
                         <groupId>org.codehaus.mojo</groupId>
                         <artifactId>build-helper-maven-plugin</artifactId>
                         <version>1.8</version>
                         <executions>
                              <execution>
                                   <id>add-source</id>
                                   <phase>generate-sources</phase>
                                   <goals>
                                        <goal>add-source</goal>
                                   </goals>
                                   <configuration>
                                        <sources>
                                             <source>src/junit/java</source>
                                             <source>src/junit/resources</source>
                                        </sources>
                                   </configuration>
                              </execution>
                         </executions>
                    </plugin>
               </plugins>
         </build>
    


     
     

     
    展开全文
  • maven配置阿里

    2019-11-26 15:00:07
    maven配置阿里

    阿里云为开发者提供了很多公共的maven仓库,解决了国内管理maven依赖缓慢不稳定的问题。
    打开maven目录中的conf文件夹,打开settings.xml文件
    进行如下配置:
    在这里插入图片描述需要注意的是这个标签,如果写成*则代表通过访问阿里云的仓库访问所有的远程仓库,配置成central则表示通过访问阿里云的仓库访问central的仓库。
    完整配置可参考下面。在这里插入图片描述

    展开全文
  • maven配置国内

    千次阅读 2020-07-09 09:58:22
    maven配置国内安装maven配置镜像找到安装目录,本文使用idea自带的maven演示,官网安装的同理进入conf目录,编辑setting.xml文件完整配置文件 安装maven 前往maven下载页下载相应系统安装包并按照提示安装,此处...

    安装maven

    前往maven下载页下载相应系统安装包并按照提示安装,此处不再赘述。

    配置镜像

    找到安装目录,本文使用idea自带的maven演示,官网安装的同理

    在这里插入图片描述

    进入conf目录,编辑setting.xml文件

    找到localRepository标签,默认为注释状态,取消注释,并在其中配置本地仓库缓存位置
    在这里插入图片描述
    配置镜像标签,在mirrors标签下新建mirror标签,注意标签内容,此处展示阿里云仓库的配置信息,具体的配置文件会在文末给出
    在这里插入图片描述
    id表示仓库唯一标识
    mirrorOf表示仓库作用范围
    name仓库名称
    url仓库位置

    完整配置文件

    <?xml version="1.0" encoding="UTF-8"?>
    
    <!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor 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 may not use this file except in compliance
    with the License.  You may obtain a copy of the License at
    
        http://www.apache.org/licenses/LICENSE-2.0
    
    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "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.
    -->
    
    <!--
     | This is the configuration file for Maven. It can be specified at two 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 be 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.conf}/settings.xml.
     |
     |                 NOTE: This location can be overridden with the CLI option:
     |
     |                 -gs /path/to/global/settings.xml
     |
     | The sections in this sample file are 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 is not 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 will use to store artifacts.
       |
       | Default: ${user.home}/.m2/repository
      
      -->
    	<localRepository>此处填写本地仓库位置</localRepository>
    	<!-- 例如
    	<localRepository>C:\Users\18769\.m2\repository</localRepository> -->
      <!-- interactiveMode
       | This will determine whether maven prompts you when it needs input. If set to false,
       | maven will 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 will have an effect on artifact downloads, artifact deployment, and others.
       |
       | Default: false
      <offline>false</offline>
      -->
    
      <!-- pluginGroups
       | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
       | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
       | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are 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 be used on this machine to connect to the network.
       | Unless otherwise specified (by system property or command-line switch), the first proxy
       | specification in this list marked as active will be used.
       |-->
      <proxies>
        <!-- proxy
         | Specification for one proxy, to be used in connecting to the network.
         |
        <proxy>
          <id>optional</id>
          <active>true</active>
          <protocol>http</protocol>
          <username>proxyuser</username>
          <password>proxypass</password>
          <host>proxy.host.net</host>
          <port>80</port>
          <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
        </proxy>
        -->
      </proxies>
    
      <!-- servers
       | This is a list of authentication profiles, keyed by the server-id used within the system.
       | Authentication profiles can be used whenever maven must make a connection to a remote server.
       |-->
      <servers>
        <!-- server
         | Specifies the authentication information to use when connecting to a particular server, identified by
         | a unique name within the system (referred to by the 'id' attribute below).
         |
         | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
         |       used together.
         |
        <server>
          <id>deploymentRepo</id>
          <username>repouser</username>
          <password>repopwd</password>
        </server>
        -->
    
        <!-- Another sample, using keys to authenticate.
        <server>
          <id>siteServer</id>
          <privateKey>/path/to/private/key</privateKey>
          <passphrase>optional; leave empty if not used.</passphrase>
        </server>
        -->
      </servers>
    
      <!-- mirrors
       | This is a list of mirrors to be used in downloading artifacts from remote repositories.
       |
       | It works like this: a POM may declare a repository to use in resolving certain artifacts.
       | However, this repository may have problems with heavy traffic at times, so people have mirrored
       | it to several places.
       |
       | That repository definition will have a unique id, so we can create a mirror reference for that
       | repository, to be used as an alternate download site. The mirror site will be the preferred
       | server for that repository.
       |-->
      <mirrors>
        <!-- mirror
         | Specifies a repository mirror site to use instead of a given repository. The repository that
         | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
         | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
         |
        <mirror>
          <id>mirrorId</id>
          <mirrorOf>repositoryId</mirrorOf>
          <name>Human Readable Name for this Mirror.</name>
          <url>http://my.repository.com/repo/path</url>
        </mirror>
         -->
    	 
    	<mirror>
        <id>aliyunmaven</id>
        <mirrorOf>*</mirrorOf>
        <name>阿里云公共仓库</name>
        <url>https://maven.aliyun.com/repository/public</url>
    	</mirror>
    	
    	<mirror>
        <id>huaweicloud</id>
        <mirrorOf>external:*,!aliyunmaven</mirrorOf>
        <name>华为云公共仓库</name>
        <url>https://mirrors.huaweicloud.com/repository/maven/</url>
    	</mirror>
    	
    	<mirror>
        <id>apachemaven</id>
        <mirrorOf>external:*,!aliyunmaven,!huaweicloud</mirrorOf>
        <name>apache公共仓库</name>
        <url>https://repo.maven.apache.org/maven2</url>
    	</mirror>
    
      </mirrors>
    
      <!-- profiles
       | This is a list of profiles which can be activated in a variety of ways, and which can modify
       | the build process. Profiles provided in the settings.xml are intended to provide local machine-
       | specific paths and repository locations which allow the build to work in the local environment.
       |
       | For example, if you have an integration testing plugin - like cactus - that needs to know where
       | your Tomcat instance is installed, you can provide a variable here such that the variable is
       | dereferenced during the build process to configure the cactus plugin.
       |
       | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
       | section of this document (settings.xml) - will be discussed later. Another way essentially
       | relies on the detection of a system property, either matching a particular value for the property,
       | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
       | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
       | Finally, the list of active profiles can be specified directly from the command line.
       |
       | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
       |       repositories, plugin repositories, and free-form properties to be used as configuration
       |       variables for plugins in the POM.
       |
       |-->
      <profiles>
      
    	
      
        <!-- profile
         | Specifies a set of introductions to the build process, to be activated using one or more of the
         | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
         | or the command line, profiles have to have an ID that is unique.
         |
         | An encouraged best practice for profile identification is to use a consistent naming convention
         | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
         | This will make it more intuitive to understand what the set of introduced profiles is attempting
         | to accomplish, particularly when you only have a list of profile id's for debug.
         |
         | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
        <profile>
          <id>jdk-1.4</id>
    
          <activation>
            <jdk>1.4</jdk>
          </activation>
    
          <repositories>
            <repository>
              <id>jdk14</id>
              <name>Repository for JDK 1.4 builds</name>
              <url>http://www.myhost.com/maven/jdk14</url>
              <layout>default</layout>
              <snapshotPolicy>always</snapshotPolicy>
            </repository>
          </repositories>
        </profile>
        -->
    
        <!--
         | Here is another profile, activated by the system property 'target-env' with a value of 'dev',
         | which provides a specific path to the Tomcat instance. To use this, your plugin configuration
         | might hypothetically look like:
         |
         | ...
         | <plugin>
         |   <groupId>org.myco.myplugins</groupId>
         |   <artifactId>myplugin</artifactId>
         |
         |   <configuration>
         |     <tomcatLocation>${tomcatPath}</tomcatLocation>
         |   </configuration>
         | </plugin>
         | ...
         |
         | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
         |       anything, you could just leave off the <value/> inside the activation-property.
         |
        <profile>
          <id>env-dev</id>
    
          <activation>
            <property>
              <name>target-env</name>
              <value>dev</value>
            </property>
          </activation>
    
          <properties>
            <tomcatPath>/path/to/tomcat/instance</tomcatPath>
          </properties>
        </profile>
        -->
      </profiles>
    
      <!-- activeProfiles
       | List of profiles that are active for all builds.
       |
      <activeProfiles>
        <activeProfile>alwaysActiveProfile</activeProfile>
        <activeProfile>anotherAlwaysActiveProfile</activeProfile>
      </activeProfiles>
      -->
    </settings>
    
    
    展开全文
  • 1.3、Maven的核心思想:约定大于配置 有约束,不要去违反。 Maven会规定好你该如何去编写我们的Java代码,必须要按照这个规范来; 2、Maven下载与配置 Maven官方下载地址 下载完成后,解压即可 ...

    1、Maven简介

    1.1、在Javaweb开发中,需要使用大量的jar包,我们手动去导入;

    1.2、如何能够让一个东西自动帮我导入和配置这个jar包。由此,Maven诞生了!

    1.3、Maven的核心思想:约定大于配置

    • 有约束,不要去违反。

    2、Maven下载与配置

    Maven官方下载地址
    在这里插入图片描述
    在这里插入图片描述
    下载完成后,解压即可。

    • 配置环境变量
      右键 此电脑 ==> 选择属性 ==> 高级系统设置 ==> 环境变量 ==> 系统变量
      在这里插入图片描述
      在这里插入图片描述
      在这里插入图片描述

      新建如下配置:

    • M2_HOME maven目录下的bin目录
      在这里插入图片描述

    • MAVEN_HOME maven的目录
      在这里插入图片描述

    • 在系统的path中配置 %MAVEN_HOME%\bin
      在这里插入图片描述

    如下图就表明Maven环境配置成功
    在这里插入图片描述

    3、Maven 配置镜像

    由于特殊原因在Maven下载Jar包速度非常慢,甚至一个工程的Jar包能下载一晚上。为了避免这种情况我们就要设置阿里云镜像。
    打开maven安装包中的conf文件夹中的settings.xml文件。
    在这里插入图片描述
    在图中所示位置添加阿里云maven镜像
    在这里插入图片描述

        <mirror>
    		<id>nexus-aliyun</id>  
    		<mirrorOf>*,!jeecg,!jeecg-snapshots</mirrorOf>  
    		<name>Nexus aliyun</name>  
    		<url>http://maven.aliyun.com/nexus/content/groups/public</url> 
        </mirror>
    

    4、建立Maven本地仓库

    如图所示:在maven文件夹中新建一个maven-repo文件夹。
    maven-repo 文件夹名称可以随便起。
    在这里插入图片描述
    在如下位置添加

    <localRepository>D:\Java\JavaWeb\apache-maven-3.6.3\maven-repo</localRepository>
    

    其中D:\Java\JavaWeb\apache-maven-3.6.3\maven-repo 是自己设置的本地仓库地址

    在这里插入图片描述

    5、IDEA中配置Maven

    5.1、新建一个maven项目
    新建好项目后在IDEA中,选择File ==> Settings。
    在这里插入图片描述
    打开Setting找到Maven,如图配置为你自己的Maven setting.xml 和maven-repo。
    在这里插入图片描述
    就可以正常的在IDEA中使用Maven了。

    展开全文
  • java之maven配置镜像

    2020-11-29 21:14:51
    jdk的路径配置 2.设置:D:\maven\apache-maven-3.6.3\conf\settings.xml D:\maven\Repository 仓库:新建文件夹进行存放下载的插件等文件 3.设置阿里: <mirror> <id>alimaven</id> <...
  • 需求Maven 为我们提供了一致的项目目录配置文件夹、资源文件夹等),在自动构建项目时, Maven 会按照这个配置来执行操作(编译源文件、拷贝资源文件)。 当 Maven 规约的默认配置不能够满足我们的需求时,我们...
  • Maven 镜像源配置

    2019-10-25 17:08:54
    setting.xml 文件 <?xml version="1.0" encoding="UTF-8"?>...settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:s...
  • 根据maven阿里云仓库推荐配置,弄的一个比较快的maven源配置 <id>aliyunmaven * 阿里云公共仓库 <url>https://maven.aliyun.com/repository/public</url> <id>spring <url>...
  • maven 配置阿里云镜像

    千次阅读 2020-09-07 14:53:20
    maven 配置阿里云镜像 打开 maven配置文件( windows 机器一般在 maven 安装目录的 conf/settings.xml ),在标签中添加 mirror 子节点: <mirror> <id>aliyunmaven</id> <mirrorOf>*...
  • 阿里云maven数据源配置

    千次阅读 2018-07-26 09:11:39
    阿里云maven数据源配置 &lt;settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="...
  • Maven数据源配置

    千次阅读 2016-09-08 22:37:35
    http://blog.sina.com.cn/s/blog_4f925fc30102ed5g.html http://www.360doc.com/content/16/0621/10/33667232_569462412.shtml
  • maven配置其他下载jar包(详细)

    千次阅读 2016-11-03 08:48:28
    在eclipse或myeclipse中,经常遇到maven下载包不完全或者没有下载下来。...配置文件下载地址:http://download.csdn.net/detail/qy20115549/9671617针对此问题,可以使用中国的进行下载jar包。以下是我在eclipse配
  • 我们知道阿里巴巴很强大,开放了一个 maven 的公开镜像,我们 maven 的 settings.xml 文件默认是从中央仓库拉取的,现在我们可以配置一个阿里镜像来解决从中央仓库拉取慢的问题! 添加 打开 settings.xml 文件,...
  • 国内访问maven中央仓库是比较慢的,往往还会出错,所以一般我们都会对maven进行修改和配置。 可以使用idea自带的maven或者使用外部自定义的maven,一般我们都是使用自定义的maven 打开maven/conf/路径,备份...
  • Maven配置

    2020-03-06 11:03:35
    配置 Maven 环境变量3. 查看 Maven 是否安装成功4. Maven 配置文件5. 修改本地仓库位置6. 添加国内镜像 1. Maven 下载 官网下载地址:http://maven.apache.org/download.cgi 注意: Maven 3.3+ 版本的需要 JDK...
  • maven配置文件

    2018-03-16 17:16:00
    修改了maven的下载 修改了maven的下载修改了maven的下载修改了maven的下载修改了maven的下载修改了maven的下载
  • 最新版Maven配置及换,下载后解压,放到个人用户目录下,就可以直接使用。如需要配置环境变量,请参考发布的博客文章。
  • 现在大多数都是使用maven管理项目所需的资源文件,可是因为maven的远程仓库多数都很难下载,所以我们可以通过配置国内镜像,配置本地maven源。 1、下载maven maven下载链接 2、maven下载后是一个压缩包,直接...
  • Linux下配置Maven中心

    2019-05-18 10:52:27
    1. Ubuntu中自带了Maven的安装,安装目录如下: yitian@heron01:/usr/share/maven/conf$ mvn -v Apache Maven 3.3.9 Maven home: /usr/share/maven Java version: 1.8.0_151, vendor: Oracle Corporation Java ...
  • 由于`Cloudera Manager`自动安装部署的`Hadoop`、`Hbase`,`Zookeeper`等组件与`Apache`提供的会有差异,所以需要配置为对应**CDH版本**的依赖包。
  • Maven配置教程

    2020-12-15 20:58:30
    Maven配置 Maven项目对象模型(POM),可以通过一小段描述信息来管理项目的构建,报告和文档的软件项目管理工具。 Maven 的配置却让一些初学者望而却步,这里我就把Maven的详细配置过程写下,希望能对你有所帮助。 ...
  • jboss maven 大多数Java EE应用程序在其业务逻辑中使用数据库访问,因此开发人员经常面临在应用程序服务器中配置驱动程序和数据库连接属性的需求。...Maven配置 首先,将以下内容添加到我们的pom.xml : Wildfl...
  • 3、将Maven安装目录添加到系统全局变量中(这一步是为了在CMD环境下,输入MAVEN相关命令,识别并执行), 操作如下: (1)我的电脑-->属性-->高级系统设置-->在“系统变量”处,新...
  • Maven配置多个文件夹

    千次阅读 2014-06-08 12:25:25
    由于一些项目并未完全按照Maven的...下面说说怎样在pom.xml中配置多个文件夹。 maven的默认结构如下: src  |-main  | |- java  | |- resource  |- webapp  |- WEB-INF 如图创建了如下错乱的目录

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 3,622
精华内容 1,448
关键字:

maven配置源