alfresco如何跟mysql结合_Alfresco入门

项目需要,最近在研究Alfresco,发现国内的资料都比较老了,这里总结一下

一、Alfresco简介

摘自百度百科

Alfresco是一款开源的企业内容管理系统(ECMS),为企业提供了日常的文档管理、协同工作、工作记录管理、知识管理、网络内容管理、图片管理等多种功能。

Alfresco是目前应用最广泛的开源企业知识管理系统。

该系统是基于Java平台开发的CMS,先后有超过150万次的下载,5万多个应用网站,7.4万个社区成员,此外,在开源社区Forge中有超过150个扩展应用。

可以说Alfresco是目前使用最广泛的企业内容管理平台(ECMS),并且她更适合管理企业内部的电子文档。

更多的内容可以查看官网

二、相关网站介绍

Source Code:之前的源码是在SVN上维护的,后来迁到了Github上,这里有老的SVN的地址

Github:各路源码和示例都在这里

Maven Repository:并没有什么用,很多依赖包都需要从Alfresco提供的私服库下载,我一开始就是没配置maven仓库,导致报各种NotFound

# 添加到maven的配置文件中

alfresco-public

https://artifacts.alfresco.com/nexus/content/groups/public

三、开发环境部署

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: customalfresco

Y: : 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

cc1eed19e502?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

Import Existing Maven Projects

选择刚刚生成的项目

[图片上传失败...(image-613219-1532049949785)]

提示错误先选择一会儿解决,finish

cc1eed19e502?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

error

在Problems的view里右键Error信息,选择Quick Fix -> Mark goal generate as ignored in pom.xml -> finish (手太快忘截图了……)

然后就是慢慢等待下载依赖,这个过程可能会很久很久很久……

到这里就可以启项目了,执行run工具

cc1eed19e502?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

execute run

经历漫长的等待,tomcat setup...

访问 http://127.0.0.1:8080/share

用户名/密码 admin / admin

Q: 我又没设置数据库,怎么服务就起来了而且还能登录?

A: 项目默认配置走的是H2Database,不了解的同学可以百度一下

看看样子吧

cc1eed19e502?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

login

[图片上传失败...(image-63105e-1532049949785)]

4. 修改配置

配置主要分布在两个地方,第一个是pom.xml里

[图片上传失败...(image-8d1472-1532049949785)]

在pom.xml中找到如下代码段,相关的配置说明参考官方文档,我们这里先简单的启动Mysql数据库

org.alfresco.maven.plugin

alfresco-maven-plugin

${alfresco.sdk.version}

**false**

**true**

true

true

true

true

${alfresco.groupId}

alfresco-share-services

${alfresco.share.version}

amp

${project.groupId}

firstblood-platform-jar

${project.version}

${project.groupId}

integration-tests

${project.version}

tests

${project.groupId}

firstblood-share-jar

${project.version}

然后就是数据库相关配置,这里也比较坑,我一开始是看官方目录结构直接在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,配置修改成功!

5. 源码依赖

如果有需要对源码修改,可以从Github上下载要需要的源码,导入Eclipse,修改上面项目的pom.xml,把对应的包的version改成你自己的即可

更多参考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

下载安装包

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=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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值