项目需要,最近在研究Alfresco,发现国内的资料都比较老了,这里总结一下
一、Alfresco简介二、相关网站介绍三、开发环境部署 1. 环境准备2. 创建项目3. 导入eclipse4. 修改配置5. 源码依赖四、安装版 下载安装包授权安装摘自百度百科
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>我这里是基于官方Github库提供的alfresco-sdk生成项目再把依赖的alfresco相关工程download下来,基本就OK了,下面说下具体步骤,官方文档上也有详细介绍
这里就不做IDE之争了……我是用惯了Eclipse,并且觉着新版的Eclipse挺好用,如果是IntelliJ IDEA大神,可以参照Setting up your development environment using Intellij IDEA
File -> Import -> Existing Maven Projects
Import Existing Maven Projects
选择刚刚生成的项目
[图片上传失败...(image-613219-1532049949785)]
提示错误先选择一会儿解决,finish
error
在Problems的view里右键Error信息,选择Quick Fix -> Mark goal generate as ignored in pom.xml -> finish (手太快忘截图了……)
然后就是慢慢等待下载依赖,这个过程可能会很久很久很久……
到这里就可以启项目了,执行run工具
execute run
经历漫长的等待,tomcat setup...
访问 http://127.0.0.1:8080/share 用户名/密码 admin / admin看看样子吧
login
[图片上传失败...(image-63105e-1532049949785)]
配置主要分布在两个地方,第一个是pom.xml里
[图片上传失败...(image-8d1472-1532049949785)]
在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好吧,看来他会根据配置的启用数据库直接找对应配置文件,所以这里直接修改上面路径下的配置文件即可
[图片上传失败...(image-4f5a9a-1532049949785)]
# 数据库,用户名,密码根据自己情况设置 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,配置修改成功!
如果有需要对源码修改,可以从Github上下载要需要的源码,导入Eclipse,修改上面项目的pom.xml,把对应的包的version改成你自己的即可
alfresco-repositoryalfresco-remote-apialfresco-greenmailalfresco-file-transfer-receiveralfresco-mbeansalfresco-mmtalfresco-server-rootalfresco-data-modelalfresco-corealfresco-xml-factoryalfresco-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.java Q5:找不到用户表…… A:这个是我一开始对alfresco理解不透彻的问题,在alfresco中所有对象都是node,像用户名密码这些都是node的property,所以请查看node相关表!暂时能想到的就这么多,有什么问题可以留言,最后再介绍一下安装版给就是想试用一下或者只需要轻度使用服务的同学
alfresco提供了安装版,可以直接安装使用,我试装的是201707版本,使用的数据库是postgresql,环境linux ubuntu16.04
过程还挺简单的,说明很明确,下面罗列一下,大家看看就好
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=libfontconfig Do you want to continue with the installation? [y/N]: y Language Selection Please 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]: y waiting for server to start....README Alfresco Community (Build: 201707) =============================== Contains: - Alfresco Platform: 5.2.g - Alfresco Share: 5.2.f For 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作者:EdgarZz 链接:https://www.jianshu.com/p/cc1eed19e502 来源:简书 简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。