运行onlyOffice官方java-spring时报错从网络上没有找到相应的文章故做下笔记
properties的参数修改
server.version=1.8.0
//配置自己的ip(如配置只能使用ip访问localhost失效)
server.address=192.168.56.1
server.port=4000
filesize-max=5242880
filename-max=50
//文件存放地址
files.storage=D:\\folder
files.storage.folder=documents
files.docservice.timeout=120000
files.docservice.history.postfix=-hist
//onlyOffice地址
files.docservice.url.site=http://192.168.56.100:8701/
files.docservice.url.converter=ConvertService.ashx
files.docservice.url.command=coauthoring/CommandService.ashx
files.docservice.url.api=web-apps/apps/api/documents/api.js
files.docservice.url.preloader=web-apps/apps/api/documents/cache-scripts.html
files.docservice.url.example=
//秘钥
files.docservice.secret=123456
files.docservice.header=Authorization
files.docservice.token-use-for-request=true
files.docservice.verify-peer-off=true
files.docservice.languages=en:English|ar:Arabic|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (Simplified)|zh-TW:Chinese (Traditional)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|sr-Latn-CS:Serbian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA:Test Language
spring.datasource.url=jdbc:h2:mem:usersdb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=password
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
hibernate.ddl-auto
spring.h2.console.enabled=true
spring.h2.console.path=/h2
spring.servlet.multipart.max-file-size=5MB
spring.servlet.multipart.max-request-size=5MB
url.index=/
url.converter=/converter
url.editor=/editor
url.track=/track
url.download=/download
添加缺失的文件
在src/main/resources/assets/document-formats路径下添加onlyoffice-docs-formats.json文件,没有搜到这个文件的示例自己从代码中摸索了几条大概满足了需求
[{"name": "docx",
"type": "word",
"actions": ["edit"]
},{"name": "pptx",
"type": "slide",
"actions": ["edit"]
},{"name": "xlsx",
"type": "cell",
"actions": ["edit"]
}]
在src/main/resources/assets/document-templates下添加目录new并在其中加入new.docx、new.pptx、new.xlsx。这些文件是新建的时候的基础模板。
修改以上内容即可运行
如有错误欢迎指正交流