- 介绍
- 环境要求
- JDK (运行环境)
- Maven (后端工程打包)
- Git (代码版本管理)
- 环境安装与使用
- 环境配置
- 安装JDK
- Windows
- Linux
- MacOS
- 友情提示
- 安装Maven (前端开发跳过)
- 一般开发配置
- 组件开发配置(重要)
- 配置文件路径
- 安装Git
- 安装PAI
- 安装
- Windows
- Linux
- MacOS
- 下载并解压
- 编辑配置文件
- 命令概览
- 常见问题
- 如何更新 pai 版本?
- 解决MacOS下readlink: illegal option – f
- 安装coreutils
- 设置环境变量
- 创建别名
- MacOS 10.15.6 zsh: command not found: 解决方法
- Win7英文版Windows执行Pai命令乱码
- win10 执行 Pai 命令返回乱码
介绍
PAI 是一款针对开发团队设计的简单好用的开发辅助工具系统。主要体现在以下几个特点:
可以通过登录开发者账号,进行快速创建项目骨架,并根据表结构快速生存模板式代码,避免开发者花费大量重复的时间在工程搭建下。
借助于对Maven的封装可以进行一系列的Maven操作,免去了下载安装配置Maven工具的时间,同时封装了运行项目和执行单元测试的能力。
- 运行项目即相当于mvn clean compile package 及 java -jar XXXX.jar。
- 执行单元测试则是相当于 mvn clean compile test。
通过对Eclipse提供的jGit进行了二次封装,可根据项目名称clone、pull、push 对远程Git仓库进行操作;可直接在项目根目录下进行 init、add、commit对本进项目进行有效的版本管理。
对远端微服务的测试环境及正式环境的部署能力。
PAI开发的主要流程:创建工程 -> 代码生成 -> 单元测试 -> 工程运行 -> 代码托管 -> 环境部署 -> 信息查看。
环境要求
PAI支持在windows、linux、MacOS操作系统中使用,使用PAI依赖JDK、Maven、Git。
JDK (运行环境)
PAI主要使用java语言开发,JDK是Java语言的软件开发工具包,是整个java开发的核心,它包含了JAVA的运行环境(JVM+Java系统类库)和JAVA工具。
Maven (后端工程打包)
pai封装了Maven,使用pai命令可以进行一系列的Maven操作,免去了下载安装配置Maven工具的时间,同时封装了运行项目和执行测试单测试的能力。
Git (代码版本管理)
pai对Eclipse提供的jGit进行了二次封装,可根据项目名称clone、pull、push 对远程Git仓库进行操作,可以直接在项目根目录下进行 init、add、commit对本进项目进行有效的版本管理。同时支持git客户端工具进行代码管理。
环境安装与使用
环境配置
安装 JDK (Widnows版、MacOS版、Linux版) 并检查配置环境变量
JAVA_HOME
如果上述连接打不开,请自行前往官网下载。
下载 Maven 解压并配置环境变量
MAVEN_HOME
(非必要,新版本pai
在找不到Maven时会自动下载到pai-cli/maven下)需把
pai-cli
目录加到path
环境变量中
安装JDK
Windows
下载并解压到指定位置。
配置JAVA_HOME,指向JDK所在目录
配置PATH,增加%JAVA_HOME%\bin
Linux
下载安装
sudo cd /usr/local \
&& curl -o amazon-corretto-8-x64-linux-jdk.tar.gz https://api.flyrise.cn/pai/jdk/amazon-corretto-8-x64-linux-jdk.tar.gz \
&& tar xzvf amazon-corretto-8-x64-linux-jdk.tar.gz \
&& rm -f amazon-corretto-8-x64-linux-jdk.tar.gz
编辑配置文件
vi ~/.bash_profile
#添加JAVA_HOME并配置到PATH
export JAVA_HOME="/usr/local/amazon-corretto-8.262.10.1-linux-x64"
export PATH="$JAVA_HOME/bin:$PATH"
加载配置文件
source ~/.bash_profile
MacOS
下载安装
sudo cd /Library/Java/JavaVirtualMachines/ \
&& curl -o amazon-corretto-8-x64-macos-jdk.tar.gz https://api.flyrise.cn/pai/jdk/amazon-corretto-8-x64-macos-jdk.tar.gz \
&& tar -zxvf amazon-corretto-8-x64-macos-jdk.tar.gz \
&& rm -f amazon-corretto-8-x64-macos-jdk.tar.gz
在终端中运行以下命令来获取完整的安装路径:
/usr/libexec/java_home --verbose
编辑配置文件
vi ~/.bash_profile
# 添加JAVA_HOME并配置到PATH
export JAVA_HOME="/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home"
export PATH="$JAVA_HOME/bin:$PATH"
加载配置文件
source ~/.bash_profile
友情提示
如果你在配置前打开了命令窗口,记得要关了重开,否则可能配置会不生效
- /etc/profile: 此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行.并从/etc/profile.d目录的配置文件中搜集shell的设置.
- /etc/bashrc: 为每一个运行bash shell的用户执行此文件.当bash shell被打开时,该文件被读取.
- ~/.bash_profile: 每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件仅仅执行一次!默认情况下,他设置一些环境变量,执行用户的.bashrc文件.
- ~/.bashrc: 该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该该文件被读取.
- ~/.bash_logout: 当每次退出系统(退出bash shell)时,执行该文件.
安装Maven (前端开发跳过)
根据IDE工具进行配置安装。
一般开发配置
一般开发的定义为:仅使用标准骨架进行业务开发,无需上传公共组件包。
- settingx.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.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.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.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>
-->
<!-- 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>insecure-repo</id>
<mirrorOf>external:http:*</mirrorOf>
<url>http://dev.flyrise.cn:8081/repository/maven-public/</url>
<!--<blocked>false</blocked>-->
</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>
<id>pai</id>
<repositories>
<repository>
<id>public</id>
<url>http://dev.flyrise.cn:8081/repository/maven-public/</url>
</repository>
</repositories>
</profile>
</profiles>
<!-- activeProfiles
| List of profiles that are active for all builds.
|
<activeProfiles>
<activeProfile>alwaysActiveProfile</activeProfile>
<activeProfile>anotherAlwaysActiveProfile</activeProfile>
</activeProfiles>
-->
<activeProfiles>
<activeProfile>pai</activeProfile>
</activeProfiles>
</settings>
组件开发配置(重要)
组件开发的定义为:开发公共Jar包,需要上传到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.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.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.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>
-->
<!-- 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>
-->
<server>
<id>releases</id>
<username>uploader</username>
<password>{gzgHcvA10/AHd/7gZ3HyEbtEnCC0u1j0gCJ4b5K6SS0=}</password>
</server>
<server>
<id>snapshots</id>
<username>uploader</username>
<password>{gzgHcvA10/AHd/7gZ3HyEbtEnCC0u1j0gCJ4b5K6SS0=}</password>
</server>
<server>
<id>z_mirrors</id>
</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>z_mirrors</id>
<mirrorOf>*,!releases,!snapshots</mirrorOf>
<url>http://dev.flyrise.cn:8081/repository/maven-public/</url>
</mirror>
<mirror>
<id>insecure-repo</id>
<mirrorOf>external:http:*</mirrorOf>
<url>http://dev.flyrise.cn:8081/repository/maven-public/</url>
<!--<blocked>false</blocked>-->
</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>
<id>pai</id>
<properties>
<altSnapshotDeploymentRepository>snapshots::default::http://dev.flyrise.cn:8081/repository/maven-snapshots/</altSnapshotDeploymentRepository>
<altReleaseDeploymentRepository>releases::default::http://dev.flyrise.cn:8081/repository/maven-releases/</altReleaseDeploymentRepository>
</properties>
<repositories>
<repository>
<id>releases</id>
<url>http://dev.flyrise.cn:8081/repository/maven-releases/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>snapshots</id>
<url>http://dev.flyrise.cn:8081/repository/maven-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<!-- activeProfiles
| List of profiles that are active for all builds.
|
<activeProfiles>
<activeProfile>alwaysActiveProfile</activeProfile>
<activeProfile>anotherAlwaysActiveProfile</activeProfile>
</activeProfiles>
-->
<activeProfiles>
<activeProfile>pai</activeProfile>
</activeProfiles>
</settings>
- settings-security.xml
用于解密settings.xml中账号的密码。
<?xml version="1.0" encoding="UTF-8"?>
<settingsSecurity>
<master>{/xljR3LWbu4HaklciMbIwrs92+OOU92NQcNdZwAlLMA=}</master>
</settingsSecurity>
配置文件路径
在开发工具中配置maven和 一般开发(setting.xml)或 组件开发(settings.xml、settings-security.xml) 相应的配置文件复制到用户目录下的.m2
目录下(不存在自己创建即可)
使用这两个配置后项目中的pom.xml则不需要配置 repositories
, 部分IDEA(如2021.3)使用的Maven是3.8.1或更高版本,会无未能正常使用,需要下载并指定为3.6.3
安装Git
pai创建的工程会放在PAI内部的git中央仓库中,如果不想使用PAI封装的git,也可以直接使用eclipse、idea等开发工具集成的git工具,但要先用pai password git 修改对应的密码。
下载地址:https://git-scm.com/downloads (Windows Portable版需手动添加到环境变量path)
使用PAI命令(pai password git)设置git仓库密码,账号与开发者账号相同
安装PAI
安装
Windows
点击此处下载 保存后解压到指定位置,并参考JDK安装配置环境变量PATH
注意:解压目录需要有读写权限且不允许有空格,否则可能会出现不断更新的情况
Linux
# 安装解压工具 unzip
# CentOS
sudo yum install -y unzip
# Ubuntu
sudo apt-get install unzip
# 下载并解压
sudo cd /usr/local && curl -o pai-cli.zip https://api.flyrise.cn/pai/wrapper/latest/pai-cli-release.zip && unzip pai-cli.zip
# 进行目录授权测试运行
sudo cd /usr/local/pai-cli && chmod 755 pai && sh pai
编辑配置文件
vi ~/.bash_profile
# 增加PAT路径配置 /usr/local/pai-cli, 注意用 : 分隔
export JAVA_HOME="/usr/local/amazon-corretto-8.262.10.1-linux-x64"
export PATH="/usr/local/pai-cli:$JAVA_HOME/bin:$PATH"
加载配置文件
source ~/.bash_profile
MacOS
下载并解压
sudo cd /usr/local
curl -o pai-cli.zip https://api.flyrise.cn/pai/wrapper/latest/pai-cli-release.zip
unzip pai-cli.zip
# 进行目录授权测试运行
cd pai-cli && chmod 755 pai && sh pai
编辑配置文件
如果是bash
终端
vi ~/.bash_profile
# 增加PAT路径配置 /usr/local/pai-cli, 注意用 : 分隔
export JAVA_HOME="/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home"
export PATH="/usr/local/pai-cli:$JAVA_HOME/bin:$PATH"
#配置文件生效
source ~/.bash_profile
如果是zsh
终端
open ~/.zshrc
# 增加PAT路径配置 /usr/local/pai-cli, 注意用 : 分隔
export JAVA_HOME="/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home"
export PATH="/usr/local/pai-cli:$JAVA_HOME/bin:$PATH"
#配置文件生效
source ~/.zshr
命令概览
Found D:\pai-cli-0.0.1\.pai\wrapper\pai-wrapper.jar
pai 是一款针对开发团队设计的简单好用的开发辅助工具
贯穿了整个套件的生命周期:创建工程 -> 代码生成 -> 单元测试 -> 工程运行 -> 代码托管 -> 环境部署 -> 信息查看
语法:
pai <命令> [参数选项]
命令:
基础命令
version 查看版本
upgrade 更新升级
changelog 更新日志
login 开发者登录
password 修改密码
开发调试
create 创建工程骨架
code 根据表结构生成代码
widget 小组件管理
form 表单管理
param 项目骨架参数
test 工程单元测试
run 运行工程
stop 停止工程
代码管理(Git)
init 将当前目录初始化为本地Git仓库
add 将代码添加到本地Git仓库
commit 提交代码到本地Git仓库
clone 从Git仓库克隆工程代码到本地
push 将本地工程代码推送到远端Git仓库
pull 从远端Git仓库拉取工程代码到本地
releases 发布工程版本
部署管理(Kubernetes)
services 查询Kubernetes服务列表
pods 查询Kubernetes应用列表
logs 读取Kubernetes应用日志
deploy 将工程部署到Kubernetes
delete 将工程从Kubernetes删除
镜像管理(Image)
image Docker镜像管理
参数:
-h,--help 使用帮助
常见问题
如何更新 pai 版本?
手动更新
手动将pai-cli
的子目录.pai\wrapper
中的pai-wrapper.jar
删除,再次运行pai -h
即可自动下载更新。命令更新
通过输入pai upgrade命令更新pai工具。
C:\Users\xxx>pai upgrade
Found D:\Joe\Tools\pai-cli-0.0.1\.pai\wrapper\pai-wrapper.jar
正在检查版本,请稍候...
已经是最新版本
解决MacOS下readlink: illegal option – f
Mac下的readlink没有-f参数,诸如screenfetch又会去调用readlink -f,于是每次都会出现:
readlink: illegal option -- f
usage: readlink [-n] [file ...]
很是烦人,解决方案如下:
安装coreutils
brew install coreutils
设置环境变量
编辑 ~/.bash_profile,添加:
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
创建别名
使用greadlink替代readlink,同样是编辑~/.bash_profile,添加:
alias readlink=greadlink
MacOS 10.15.6 zsh: command not found: 解决方法
在bash_profile配置了环境变量,还是用不了pai?
把 bash shell 中.bash_profile 全部环境变量加入zsh shell里就好
第一步:
在终端执行open ~/.zshrc
第二步
找到 “# User configuration”
在其下面添加下面内容source ~/.bash_profile
如果没有’# User configuration’,就直接把上面内容添加到 ~/.zshrc
里面
第三步
在终端里执行source ~/.zshrc
Win7英文版Windows执行Pai命令乱码
打开控制面的(Control Panel)
设置显示格式为: Chinese(Simplified,RPC)
Administrative > Language for non-Unicode programs > Change System locale… 设置为chinese。
win10 执行 Pai 命令返回乱码
解决方案:
开始–>计算机–>鼠标反键(鼠标右键)–>属性–>高级系统设置–>环境变量–>系统变量
新建。然后输入:“JAVA_TOOL_OPTIONS”变量,值为“-Dfile.encoding=UTF-8”