Maven settings

maven的配置文件 是在maven 的安装目录下的conf目录下
这里写图片描述
该文章只是我记录一下我们在使用maven 中肯能用的一些配置备忘。
settings.xml的配置

<?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.home}/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>/path/to/local/repo</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>

    <server>
        <id>yxqm_mvn</id>
        <username>dev</username>
        <password>123456</password>
        <configuration>
        <httpConfiguration>
         <all>
          <usePreemptive>true</usePreemptive>
         </all>
        </httpConfiguration>
       </configuration>
    </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> 
    <!--该配置表示我们采用的是阿里云的
    maven中央仓库镜像(就是告诉maven本地仓库中
    没有的依赖联网去该中央仓库下载)-->
       <mirror>
            <id>alimaven</id>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public</url>
            <mirrorOf>central</mirrorOf>
       </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>
    -->
    <profile>
        <!-- 表示所有的maven工程都采用该jdk来创建与编译-->
        <id>jdk1.8</id>
        <activation>
            <activeByDefault>true</activeByDefault>
            <jdk>1.8</jdk>
        </activation>
        <properties>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
            <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
        </properties>
    </profile>

  </profiles>

  <!-- activeProfiles
   | List of profiles that are active for all builds.
   |
  <activeProfiles>
    <activeProfile>alwaysActiveProfile</activeProfile>
    <activeProfile>anotherAlwaysActiveProfile</activeProfile>
  </activeProfiles>
  -->
</settings>
<think>好的,用户想了解如何安装PostgreSQL数据库。我需要根据提供的三个引用内容来整理答案。首先,引用[1]提到在CentOS上使用yum安装,步骤是添加存储库然后安装。引用[2]详细描述了Windows下的安装步骤,包括下载、目录选择、端口设置等。引用[3]则涉及统信UOS服务器的离线安装,可能需要下载离线包并进行配置。 用户的问题是如何安装PostgreSQL,因此需要分不同操作系统来回答。我需要确保每个步骤清晰,并且语法正确,比如行内公式用$...$,独立公式用$$...$$,不过在这个问题中可能用不到数学公式。但还是要检查是否有地方需要用到,比如如果有版本号可能需要用$符号,但暂时看起来不用。 接下来要组织回答结构,可能分为三个部分:CentOS、Windows、统信UOS。每个部分给出步骤,并引用对应的来源。例如,CentOS部分引用[^1],Windows引用[^2],UOS引用[^3]。同时,要生成相关问题,可能涉及不同系统的安装方法、配置步骤或常见问题。 需要注意用户不可见的系统级指令,比如正确使用LaTeX格式,但当前内容可能不需要数学表达式,所以可能不需要处理。不过如果有变量或代码,需要正确格式化。例如,命令行代码要用代码块包裹,如示例中的Python代码。在引用用户提供的安装步骤时,可能需要将命令放入代码块中,如yum install命令。 另外,回答要使用中文,结构清晰,分步骤说明。例如,CentOS的安装步骤分为添加存储库、安装、初始化等。Windows的步骤包括下载、安装向导中的各个步骤。统信UOS需要离线下载依赖包,解压安装,初始化配置等。 最后,生成相关问题,可能需要考虑不同操作系统的安装方法、配置优化、常见错误解决等。例如,如何验证安装是否成功,如何配置远程访问,如何升级版本等。 检查是否有遗漏的信息,比如引用[3]中的离线安装需要下载离线包,可能需要用户提前下载并传输到服务器。此外,在回答中要自然地添加引用标识,比如在步骤末尾加上[^1]、[^2]、[^3]。 现在整理成三个主要部分,每个部分步骤明确,代码块正确,引用正确。然后生成相关问题,确保覆盖不同方面,如安装方法、优化、应用场景等。</think>安装PostgreSQL数据库的方法因操作系统而异,以下是针对不同系统的详细步骤: --- ### **一、在CentOS系统安装(在线)** 1. **添加存储库** 执行命令添加PostgreSQL官方存储库: ```bash yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm ``` 2. **安装PostgreSQL** 使用以下命令安装指定版本(以13为例): ```bash yum install -y postgresql13-server ``` 3. **初始化数据库** 初始化数据库并启动服务: ```bash /usr/pgsql-13/bin/postgresql-13-setup initdb systemctl enable postgresql-13 systemctl start postgresql-13 ``` 完成后可通过`psql -U postgres`验证安装--- ### **二、在Windows系统安装(图形化向导)** 1. **下载安装包** 访问[PostgreSQL官网](https://www.postgresql.org/download/),选择Windows版本下载。 2. **运行安装向导** - 选择安装目录(如`C:\Program Files\PostgreSQL\13`)[^2] - 设置数据存储路径(如`C:\PostgreSQL\data`) - 配置端口(默认`5432`)管理员密码 3. **完成安装** 勾选“启动Stack Builder”安装额外工具(可选),通过开始菜单打开**pgAdmin**验证。 --- ### **三、在统信UOS系统离线安装** 1. **下载离线包** 从官网获取PostgreSQL的离线安装包(如`.deb`或源码包)。 2. **安装依赖** 将依赖包传输到服务器,使用`dpkg`命令手动安装: ```bash dpkg -i postgresql-13.deb libpq5.deb ``` 3. **初始化与配置** 创建数据目录并授权: ```bash mkdir /var/lib/postgresql chown postgres:postgres /var/lib/postgresql sudo -u postgres initdb -D /var/lib/postgresql/data ``` 修改配置文件`postgresql.conf`启用远程访问(如需)。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值