簡單敘述如何將Library 從私有的maven倉儲加入到專案內
Eclipse 如何轉換成maven project
專案上按右鍵 > Configure > Convert to Maven Project

因為是私有倉儲,必須加入以下這段到pom.xml 來指定倉儲,才能找到
<repositories>
<repository>
<id>AM</id>
<url>http://127.0.0.1:8082/artifactory/lib/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
這段是指定所需要的Library 位置
<dependencies>
<dependency>
<groupId>AM</groupId>
<artifactId>JavaServerLibrary</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
接下來如果需要更新版本,只需要修改version 內的數值即可
設定好後,可以進去專案Java Build Path 裡面就可以看到 maven 已經將指定的版本部署好

接下來是IntelliJ 的簡單設定方式
按 command + 分號 打開project 設定,裡面會有載入的library 跟maven 相關jar 檔


勾起後就會看到pom.xml 檔案
注意:新版intellj 才支援外掛Repository,舊的會壞掉無法連線
壞掉:transfer for nexus-maven-repository-index.properties failed intellij,更新intellj可以解決
但是新版的必須在 settings.xml 加上這段,才能使用http 倉儲….
<mirrors>
<mirror>
<id>maven-default-http-blocker</id>
<mirrorOf>external:http:*</mirrorOf>
<name>PseudorepositorytomirrorexternalrepositoriesinitiallyusingHTTP.</name>
<url>http://127.0.0.1:8082/artifactory/lib</url>
</mirror>
</mirrors>
以下為pom.xml / settings.xml 的完整內容
pom.xml
路徑:專案路徑/pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>TI_FakePortServer</groupId>
<artifactId>TI_FakePortServer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>AM</id>
<url>http://127.0.0.1:8082/artifactory/lib</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>AM</groupId>
<artifactId>JavaServerLibrary</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>
settings.xml
路徑 /users/quanto/.m2/settings.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:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>/users/quanto/.m2/repository</localRepository>
<mirrors>
<mirror>
<id>maven-default-http-blocker</id>
<mirrorOf>external:http:*</mirrorOf>
<name>Pseudo repository to mirror external repositories initially using HTTP.</name>
<url>http://127.0.0.1:8082/artifactory/lib</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>jdk-1.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>
</settings>