回應

URL Link //n.sfs.tw/11603

2017-08-11 19:04:10 By jung

1. before you start to download dependencies for maven project, you should add settings.xml to your username's ".m2"folder, in order to download private packages
according to: http://www.codedata.com.tw/java/understanding-gradle-2-maven/
透過『宣告』相依性的方法在替專案增加相依函式庫,將專案原始碼與函式庫分開處理,方便了版本控制系統的使用。編譯成果會被放在 target 目錄下,除了 target 目錄的內容,其他都是需要進版本控制系統的『資料』。而函式庫會由 Maven 透過 repostiory server 下載,並 cache 在使用者目錄下的 /.m2 目錄

written those texts into your "settings.xml",and save to your user home directory's ".m2" folder

########################以下為新增內容#################

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd";;;;;;; xmlns="http://maven.apache.org/SETTINGS/1.1.0"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <servers>
   <server>
     <username>attention!!must insert your own user name on JFrog Artifactory</username>
     <password>and your own password here!!</password>
     <id>oidcrs-release</id>
   </server>
 </servers>
 <!--
 <profiles>
   <profile>
     <repositories>
       <repository>
         <snapshots>
           <enabled>false</enabled>
         </snapshots>
         <id>central</id>
         <name>libs-release</name>
         <url>https://oidcrs.tanet.edu.tw/artifactory/libs-release</url>
       </repository>
     </repositories>
     <id>artifactory</id>
   </profile>
 </profiles>
 <activeProfiles>
   <activeProfile>artifactory</activeProfile>
 </activeProfiles>
 -->
</settings>

###########################################################################

then restart your netbeans.

 

2. maven java application project's pom.xml revised as followng:

如 "http://n.sfs.tw/content/index/11551
提到的,在新增maven專案後,到該專案的pom.xml修改如下:

<?xml version="1.0" encoding="UTF-8"?>
<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>rest</groupId>
    <artifactId>IDP001</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
###以下為新增的部分#####################   

<dependencies>
        <dependency>
            <groupId>tc.edu</groupId>
            <artifactId>cnclibs</artifactId>
            <version>0.0.1</version>
        </dependency>
</dependencies>
<repositories>
    <repository>
        <id>oidcrs-release</id>
        <url>https://oidcrs.tanet.edu.tw/artifactory/libs-release</url>
    </repository>
</repositories>

#####以上是新增的部分##################

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>    
</project>

============================================================

then, after you saved pom.xml in netbeans, you can right click on your netbeans project name, and choose to reload POM,

after doing that, right click on your project's dependencies folder, choose to "download declared dependencies"

 

3. doing the same thing from here五、建立Other Source