Centos7部署OnlyOffice DocumentServer Java-Spring Example的过程扫雷

https://api.onlyoffice.com/editors/example/javaspring 的过程写得过于粗略,很多指令也不适用于Centos,所以踩了很多坑。具体如下:

Step 1. Install ONLYOFFICE Docs
Download and install ONLYOFFICE Docs (packaged as Document Server).

See the detailed guide to learn how to install Document Server for Linux.

这一步没什么好说的,直接docker跑一下OnlyOffice Docs基础服务就行,见https://helpcenter.onlyoffice.com/installation/docs-community-install-docker.aspx?_ga=2.51711023.782359554.1594636128-1157782750.1587541027

Step 2. Install the prerequisites and run the website with the editors
Install Java:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java11-installer

一般Centos没有apt-get,也不建议装,直接用yum装就可以。注意两个问题:一是最好安装java 11,与配置文件中的配置相符。我一开始用的Java1.8,居然报了好多语法错误。二是要装JDK,带javac那个版本的,Maven会用到。可参考https://www.jianshu.com/p/240d8d00fa59,把里面的1.8改成11就行,即安装java-11-openjdk-devel.x86_64。装完之后echo \(JAVA_HOME,确认环境变量配置正确即可。如果没有配置环境变量,参考https://www.cnblogs.com/lenmom/p/9494877.html。注意检查\)JAVA_HOME/bin/目录下是否存在javac,不存在的话就是错误的路径。我的JAVA_HOME是
/usr/lib/jvm/java-11-openjdk-11.0.13.0.8-1.el7_9.x86_64,仅供参考。

There are two ways to get the Java-Spring example:

download the archive with the Java-Spring example and unpack it:

wget https://api.onlyoffice.com/app_data/editor/Java-Spring Example.zip
unzip Java-Spring\ Example.zip
clone the git repository:

git clone https://github.com/ONLYOFFICE/document-server-integration.git

官网上下载的压缩包可能是损坏的,解压不出来。我也试了把Windows版本拷贝过去,和Linux版差异很大,不能用。所以只能git clone。好在大部分centos都装了git。如果连不上github的话,自行百度解决吧。

Change the current directory for the project directory:

in the archive:

cd Java-Spring\ Example
in the git repository:

cd document-server-integration/web/documentserver-example/java-spring

本文用的git仓库,所以执行第二个指令

Edit the application.properties configuration file. Specify the name of your local server with the ONLYOFFICE Docs installed.
nano src/main/resources/application.properties
Edit the following lines:

server.address=address
server.port=port
files.docservice.url.site=https://documentserver/

files.docservice.url.site写部署了OnlyOffice Doc基础服务的主机IP就行,注意检查是否能ping通。如果部署OnlyOffice Doc时没有配置https的话,老老实实用http连接吧。

Install Maven:
sudo apt-get install maven

参考https://blog.csdn.net/weixin_43730492/article/details/109528628

Build:
mvn package

如果前面jdk11没装对,这里大概率报错“无效的源发行版>11”之类的。坑

Start Java-Spring example:

./mvnw spring-boot:run

最坑的部分来了,项目里没有预装maven wrapper,直接执行的话会报maven-wrapper.jar: No such file or directory。需要先执行mvn -N io.takari:maven:0.7.7:wrapper。
再执行./mvnw spring-boot:run,直到命令行显示Started IntegrationApplication in 8.234 seconds (JVM running for 9.013)
访问address:port,出现如同Doc服务自带的example同样的界面,大概就是完成部署了

但不知为何,只能上传文件并编辑,无法新建文件。

posted @ 2021-12-27 11:27  答案唯一的四重选择题  阅读(851)  评论(0)    收藏  举报