Alfresco入门
項目需要,最近在研究Alfresco,發現國內的資料都比較老了,這里總結一下
- 一、Alfresco簡介
- 二、相關網站介紹
- 三、開發環境部署
- 1. 環境準備
- 2. 創建項目
- 3. 導入eclipse
- 4. 修改配置
- 5. 源碼依賴
- 四、安裝版
- 下載安裝包
- 授權
- 安裝
一、Alfresco簡介
摘自百度百科
Alfresco是一款開源的企業內容管理系統(ECMS),為企業提供了日常的文檔管理、協同工作、工作記錄管理、知識管理、網絡內容管理、圖片管理等多種功能。 Alfresco是目前應用最廣泛的開源企業知識管理系統。 該系統是基于Java平臺開發的CMS,先后有超過150萬次的下載,5萬多個應用網站,7.4萬個社區成員,此外,在開源社區Forge中有超過150個擴展應用。 可以說Alfresco是目前使用最廣泛的企業內容管理平臺(ECMS),并且她更適合管理企業內部的電子文檔。更多的內容可以查看官網
二、相關網站介紹
Project Overview:項目概述
Source Code:之前的源碼是在SVN上維護的,后來遷到了Github上,這里有老的SVN的地址
Github:各路源碼和示例都在這里
Maven Repository:并沒有什么用,很多依賴包都需要從Alfresco提供的私服庫下載,我一開始就是沒配置maven倉庫,導致報各種NotFound
# 添加到maven的配置文件中 <repository><id>alfresco-public</id><url>https://artifacts.alfresco.com/nexus/content/groups/public</url> </repository>三、開發環境部署
1. 環境準備
- JAVA - MAVEN(記得上面說的修改配置文件添加倉庫) - IDE(隨你喜歡,記得IDE中maven插件走的是上步修改過的配置文件)我這里是基于官方Github庫提供的alfresco-sdk生成項目再把依賴的alfresco相關工程download下來,基本就OK了,下面說下具體步驟,官方文檔上也有詳細介紹
2. 創建項目
# 1. alfresco-sdk下載 git clone https://github.com/Alfresco/alfresco-sdk.git # 2. 構建,要跳過test,test中會有連接配置中數據庫等操作,之后我們再說改配置文件的問題,這里跳過 cd alfresco-sdk mvn clean install -Dmaven.test.skip=true # 3. 生成擴展項目 mvn archetype:generate -DarchetypeCatalog=local # 4. 提示選擇原型,選擇all-in-one,具體區別可以參照官方文檔 [INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0) Choose archetype: 1: local -> org.alfresco.maven.archetype:alfresco-platform-jar-archetype (Sample project with full support for lifecycle and rapid development of Platform/Repository JARs and AMPs (Alfresco Module Packages)) 2: local -> org.alfresco.maven.archetype:alfresco-share-jar-archetype (Share project with full support for lifecycle and rapid development of JARs and AMPs (Alfresco Module Packages)) 3: local -> org.alfresco.maven.archetype:alfresco-allinone-archetype (Sample multi-module project for All-in-One development on the Alfresco plaftorm. Includes modules for Platform/Repository JAR and Share JAR) 4: local -> org.alfresco.maven.archetype:activiti-jar-archetype (DEPRECATED - UNSUPPORTED - EXPERIMENTAL) Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): **3** # 5. 設置groupId,根據自己情況起,這里我們叫customalfresco Define value for property 'groupId': customalfresco # 6. 設置artifactId,同樣根據自己情況來,這里我們叫firstblood Define value for property 'artifactId': firstblood # 7. 設置package名,默認使用groupId,看自己情況,默認的話直接回車 Define value for property 'package' customalfresco: : # 8. 確認配置,Y Confirm properties configuration: groupId: customalfresco artifactId: firstblood version: 1.0-SNAPSHOT package: customalfrescoY: : y # 9. 等待 [INFO] ---------------------------------------------------------------------------- [INFO] Using following parameters for creating project from Archetype: alfresco-allinone-archetype:3.0.2-SNAPSHOT [INFO] ---------------------------------------------------------------------------- [INFO] Parameter: groupId, Value: customalfresco [INFO] Parameter: artifactId, Value: firstblood [INFO] Parameter: version, Value: 1.0-SNAPSHOT [INFO] Parameter: package, Value: customalfresco [INFO] Parameter: packageInPathFormat, Value: customalfresco [INFO] Parameter: package, Value: customalfresco [INFO] Parameter: version, Value: 1.0-SNAPSHOT [INFO] Parameter: groupId, Value: customalfresco [INFO] Parameter: artifactId, Value: firstblood [INFO] Parent element not overwritten in D:\work\projects\alfresco\source-zip\alfresco-sdk-master\firstblood\firstblood-platform-jar\pom.xml [INFO] Parent element not overwritten in D:\work\projects\alfresco\source-zip\alfresco-sdk-master\firstblood\firstblood-share-jar\pom.xml [INFO] Parent element not overwritten in D:\work\projects\alfresco\source-zip\alfresco-sdk-master\firstblood\integration-tests\pom.xml [INFO] Project created from Archetype in dir: D:\work\projects\alfresco\source-zip\alfresco-sdk-master\firstblood [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] Alfresco SDK ....................................... SUCCESS [07:02 min] [INFO] Rapid Application Development Support .............. SKIPPED [INFO] Alfresco Maven Plugin .............................. SKIPPED [INFO] Alfresco SDK - Platform JAR Archetype .............. SKIPPED [INFO] Alfresco SDK - Share JAR Archetype ................. SKIPPED [INFO] Alfresco SDK - All-in-One Archetype ................ SKIPPED [INFO] DEPRECATED - UNSUPPORTED - EXPERIMENTAL: Alfresco SDK - Activiti JAR Archetype SKIPPED [INFO] AIO - SDK 3.0 ...................................... SKIPPED [INFO] Alfresco Platform/Repository JAR Module ............ SKIPPED [INFO] Alfresco Share JAR Module .......................... SKIPPED [INFO] Integration Tests Module ........................... SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 07:04 min [INFO] Finished at: 2018-07-19T23:20:36+08:00 [INFO] Final Memory: 20M/224M [INFO] ------------------------------------------------------------------------ # 大功告成!可以看到剛剛的配置、項目目錄等信息3. 導入eclipse
這里就不做IDE之爭了……我是用慣了Eclipse,并且覺著新版的Eclipse挺好用,如果是IntelliJ IDEA大神,可以參照Setting up your development environment using Intellij IDEA
File -> Import -> Existing Maven Projects
選擇剛剛生成的項目
提示錯誤先選擇一會兒解決,finish
在Problems的view里右鍵Error信息,選擇Quick Fix -> Mark goal generate as ignored in pom.xml -> finish (手太快忘截圖了……)
然后就是慢慢等待下載依賴,這個過程可能會很久很久很久……
到這里就可以啟項目了,執行run工具
經歷漫長的等待,tomcat setup…
訪問 http://127.0.0.1:8080/share 用戶名/密碼 admin / adminQ: 我又沒設置數據庫,怎么服務就起來了而且還能登錄? A: 項目默認配置走的是H2Database,不了解的同學可以百度一下
看看樣子吧
4. 修改配置
配置主要分布在兩個地方,第一個是pom.xml里
在pom.xml中找到如下代碼段,相關的配置說明參考官方文檔,我們這里先簡單的啟動Mysql數據庫
<plugin><groupId>org.alfresco.maven.plugin</groupId><artifactId>alfresco-maven-plugin</artifactId><version>${alfresco.sdk.version}</version><configuration><!-- We need the flat file H2 database to run the Repo -->**<enableH2>false</enableH2>****<enableMySQL>true</enableMySQL>**<!-- We always need the Platform/Repo webapp - alfresco.war --><enablePlatform>true</enablePlatform><!-- Enable Solr webapp so we can use search --><enableSolr>true</enableSolr><!-- We need Share webapp, so we got a UI for working with the Repo --><enableShare>true</enableShare><!-- Enable the REST API Explorer --><enableApiExplorer>true</enableApiExplorer><!--JARs and AMPs that should be overlayed/applied to the Platform/Repository WAR(i.e. alfresco.war)--><platformModules><!-- Share Services will be ignored if you are on Platform earlier than 5.1 --><moduleDependency><groupId>${alfresco.groupId}</groupId><artifactId>alfresco-share-services</artifactId><version>${alfresco.share.version}</version><type>amp</type></moduleDependency><!-- Bring in custom Modules --><moduleDependency><groupId>${project.groupId}</groupId><artifactId>firstblood-platform-jar</artifactId><version>${project.version}</version></moduleDependency><!-- Bring in the integration tests --><moduleDependency><groupId>${project.groupId}</groupId><artifactId>integration-tests</artifactId><version>${project.version}</version><classifier>tests</classifier></moduleDependency></platformModules><!--JARs and AMPs that should be overlayed/applied to the Share WAR (i.e. share.war)--><shareModules><!-- Bring in custom Modules --><moduleDependency><groupId>${project.groupId}</groupId><artifactId>firstblood-share-jar</artifactId><version>${project.version}</version></moduleDependency></shareModules></configuration> </plugin>然后就是數據庫相關配置,這里也比較坑,我一開始是看官方目錄結構直接在src/main/resources/下創建了配置文件alfresco-global.properties,在里面添加了數據庫相關配置,然后并沒有用……觀察啟動日志發現了一句神奇的命令:
rename src/test/properties/local/alfresco-global-mysql.properties -> xxxx/alfresco-global.properties好吧,看來他會根據配置的啟用數據庫直接找對應配置文件,所以這里直接修改上面路徑下的配置文件即可
# 數據庫,用戶名,密碼根據自己情況設置 db.driver=org.gjt.mm.mysql.Driver db.url=jdbc:mysql://localhost:3306/alfrescoaio?useUnicode=yes&characterEncoding=UTF-8 db.username=alfresco db.password=alfresco db.pool.initial=10 db.pool.max=100重新調用run命令,會發現配置的數據庫下新增了很多表,成功啟動,登錄OK,配置修改成功!
5. 源碼依賴
如果有需要對源碼修改,可以從Github上下載要需要的源碼,導入Eclipse,修改上面項目的pom.xml,把對應的包的version改成你自己的即可
alfresco-repository
alfresco-remote-api
alfresco-greenmail
alfresco-file-transfer-receiver
alfresco-mbeans
alfresco-mmt
alfresco-server-root
alfresco-data-model
alfresco-core
alfresco-xml-factory
alfresco-legacy-lucene
更多參考Github吧,就不一一列舉了
這里說幾個在導入源碼時遇到的一些問題
Q1: Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:aspectj-maven-plugin:1.3.1:compile A: 官方解決方案:https://www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html也可以使用eclipse的Quick Fix,同上面操作Q2: mvn clean install報錯 A:應該都是test的錯誤,忽略test:mvn clean install -Dmaven.test.skip=true Q3:mvn install過程中報依賴包NotFound A:沒有按照開始說的把Alfresco的私服庫添加到maven配置文件中Q4:希望是我的個例,mvn install沒問題,工程里報class not found A:這個真是一臉懵……只好找到對應的類自己加進入,可以去這里找找看:https://programtalk.com/vs/?source=community-edition/projects/remote-api/source/generated/org/alfresco/rest/antlr/WhereClauseParser.javaQ5:找不到用戶表…… A:這個是我一開始對alfresco理解不透徹的問題,在alfresco中所有對象都是node,像用戶名密碼這些都是node的property,所以請查看node相關表!暫時能想到的就這么多,有什么問題可以留言,最后再介紹一下安裝版給就是想試用一下或者只需要輕度使用服務的同學
四、安裝版
alfresco提供了安裝版,可以直接安裝使用,我試裝的是201707版本,使用的數據庫是postgresql,環境linux ubuntu16.04
下載安裝包
https://sourceforge.net/projects/alfresco/files/Alfresco%20201707%20Community/ 選擇alfresco-community-installer-201707-linux-x64.bin授權
chmod +x alfresco-community-installer-201707-linux-x64.bin安裝
過程還挺簡單的,說明很明確,下面羅列一下,大家看看就好
root@ubuntu226:/home/fabric/workspace/alfresco# ls alfresco-community-installer-201707-linux-x64.bin root@ubuntu226:/home/fabric/workspace/alfresco# ./alfresco-community-installer-201707-linux-x64.bin Some or all of the libraries needed to support LibreOffice were not found on your system: fontconfig libSM libICE libXrender libXext libcups libGLU libcairo2 libgl1-mesa-glx You are strongly advised to stop this installation and install the libraries. For more information, see the LibreOffice documentation at http://docs.alfresco.com/search/site/all?keys=libfontconfigDo you want to continue with the installation? [y/N]: yLanguage SelectionPlease select the installation language [1] English - English [2] French - Fran?ais [3] Spanish - Espa?ol [4] Italian - Italiano [5] German - Deutsch [6] Japanese - 日本語 [7] Dutch - Nederlands [8] Russian - Русский [9] Simplified Chinese - 簡體中文 [10] Norwegian - Norsk bokm?l [11] Brazilian Portuguese - Português Brasileiro Please choose an option [1] : 9 ---------------------------------------------------------------------------- 歡迎來到 Alfresco Community 安裝程序。---------------------------------------------------------------------------- 安裝類型[1] 簡單 - 使用默認配置安裝。 [2] 高級 - 配置服務器端口和服務屬性。: 還可以選擇要安裝的可選組件。 請選擇選項 [1] : 1---------------------------------------------------------------------------- 安裝文件夾請選擇要安裝 Alfresco Community 的文件夾。選擇文件夾: [/opt/alfresco-community]: ---------------------------------------------------------------------------- 數據庫服務器參數請輸入數據庫端口。數據庫服務器端口: [5432]: 3306---------------------------------------------------------------------------- 管理密碼請指定 Alfresco Content Services 管理員帳戶的密碼。管理密碼: : 確認密碼: : ---------------------------------------------------------------------------- 作為服務安裝如果您將 Alfresco Community 注冊為一項服務,機器啟動時,將會自動啟動 Alfresco Community。將 Alfresco Community 作為服務安裝? [Y/n]: y^H如果您將 Alfresco Community 注冊為一項服務,機器啟動時,將會自動啟動 Alfresco Community。將 Alfresco Community 作為服務安裝? [Y/n]: y---------------------------------------------------------------------------- 警告此環境沒有為 Alfresco Content Services 進行優化配置 - 請仔細閱讀此列表后再繼續操作。雖然這些問題不會妨礙 Alfresco Content Services 正常運行,但有些產品功能可能不可用,或者系統可能無法發揮最佳性能。CPU clock speed is too slow(2.0 GHz+): 1.79 GHz按 [Enter] 繼續:---------------------------------------------------------------------------- 安裝程序已經準備好將 Alfresco Community 安裝到您的電腦。您確定要繼續嗎? [Y/n]: ---------------------------------------------------------------------------- 正在安裝 Alfresco Community 至您的電腦中,請稍候。正在安裝0% ______________ 50% ______________ 100%#########################################---------------------------------------------------------------------------- 安裝程序已經將 Alfresco Community 安裝于您的電腦中。瀏覽自述文件 [Y/n]: y啟動 Alfresco Community [Y/n]: ywaiting for server to start....README Alfresco Community (Build: 201707) ===============================Contains:- Alfresco Platform: 5.2.g- Alfresco Share: 5.2.fFor users of Alfresco Community Edition, more information on this release is available at https://community.alfresco.com/community/ecm按 [Enter] 繼續: done server started /opt/alfresco-community/postgresql/scripts/ctl.sh : postgresql started at port 3306 Using CATALINA_BASE: /opt/alfresco-community/tomcat Using CATALINA_HOME: /opt/alfresco-community/tomcat Using CATALINA_TMPDIR: /opt/alfresco-community/tomcat/temp Using JRE_HOME: /opt/alfresco-community/java Using CLASSPATH: /opt/alfresco-community/tomcat/bin/bootstrap.jar:/opt/alfresco-community/tomcat/bin/tomcat-juli.jar Using CATALINA_PID: /opt/alfresco-community/tomcat/temp/catalina.pid Tomcat started. /opt/alfresco-community/tomcat/scripts/ctl.sh : tomcat started總結
以上是生活随笔為你收集整理的Alfresco入门的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 魔兽争霸 宽屏笔记本无法全屏解决办法
- 下一篇: windows 解压缩命令