|
|
2 лет назад | |
|---|---|---|
| documents/5242880 | 2 лет назад | |
| licenses | 2 лет назад | |
| src/main | 2 лет назад | |
| target/classes | 2 лет назад | |
| 3rd-Party.license | 2 лет назад | |
| Dockerfile | 2 лет назад | |
| LICENSE | 2 лет назад | |
| README.md | 2 лет назад | |
| checkstyle-suppressions.xml | 2 лет назад | |
| checkstyle.xml | 2 лет назад | |
| docker-compose.yaml | 2 лет назад | |
| integration.iml | 2 лет назад | |
| mvnw | 2 лет назад | |
| mvnw.cmd | 2 лет назад | |
| onlyoffice.header | 2 лет назад | |
| pom.xml | 2 лет назад |
This example will help you integrate ONLYOFFICE Docs into your web application written in Java with Spring Boot.
Spring Boot has a lot of functionality, but its most significant features are: dependency management, auto-configuration, and built-in servlet containers.
Please note: It is intended for testing purposes and demonstrating functionality of the editors. Do NOT use this integration example on your own server without proper code modifications! In case you enabled the test example, disable it before going for production.
Download and install ONLYOFFICE Docs (packaged as Document Server).
See the detailed guide to learn how to install Document Server for Windows.
Download the Java-Spring example from our site.
To connect the editors to your website, specify the path to the editors installation, server port and the path to the storage folder in the \src\main\resources\application.properties file:
files.storage=
server.port=port
files.docservice.url.site=https://documentserver/
where the documentserver is the name of the server with the ONLYOFFICE Docs installed, port is any available port and files.storage is the path where files will be created and stored (in the project folder by default). You can set an absolute path. For example, D:\\folder. Please note that on Windows OS the double backslash must be used as a separator.
If you want to experiment with the editor configuration, modify the parameters it the \src\main\resources\editor.html file.
To run the Java example code, install the Java version 11 appropriate for your OS and framework Apache Maven:
After you have installed Java on Windows, set the JAVA_HOME environment variable to point to the Java installation directory.
Find out where Java is installed. If you didn't change the path during installation, it will be something like this:
C:\Program Files\Java\jdk11
In Windows 7 right click My Computer and select Properties, then click Advanced.
In Windows 8 go to Control Panel -> System -> Advanced System Settings.
Click the Environment Variables button.
Under System Variables, click New.
In the Variable Name field, enter JAVA_HOME if you installed the JDK (Java Development Kit) or JRE_HOME if you installed the JRE (Java Runtime Environment).
In the Variable Value field, enter your JDK or JRE installation path, for example C:\Program Files\Java\jdk11.
Check if the variable created successfully by echo command in the Command Prompt:
echo %JAVA_HOME%
Set the MAVEN_HOME environment variable:
Unzip the downloaded archive with the maven to any directory, it will be something like this:
C:\apache-maven-3.8.1
In Windows 7 right click My Computer and select Properties, then click Advanced.
In Windows 8 go to Control Panel -> System -> Advanced System Settings.
Click the Environment Variables button.
Under System Variables, click New.
In the Variable Name field, enter MAVEN_HOME.
In the Variable Value field, enter your JDK or JRE installation path, for example C:\apache-maven-3.8.1.
Add C:\apache-maven-3.8.1\bin to the PATH system variable: In system variables, find PATH, clicks on the Edit... button. In “Edit environment variable” dialog, clicks on the New button and add this C:\apache-maven-3.8.1\bin
Check if the variable created successfully by echo command in the Command Prompt:
echo %MAVEN_HOME%
cd C:\Program Files\document-server-integration\web\documentserver-example\java-spring
mvn clean
mvn package
mvn spring-boot:run
Open your browser using server.address and server.port:
http://server.address:server.port/
In case the example and Document Server are installed on different computers, make sure that your server with the example installed has access to the Document Server with the address which you specify instead of documentserver in the configuration files.
Make sure that the Document Server has access to the server with the example installed with the address which you specify instead of example.com in the configuration files.
Download and install ONLYOFFICE Docs (packaged as Document Server).
See the detailed guide to learn how to install Document Server for Linux.
Install Java:
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java11-installer
Download the archive with the Java-Spring example and unpack the archive or clone git repository:
a) archive with Java-Spring:
wget https://api.onlyoffice.com/app_data/editor/Java%20Spring%20Example.zip
unzip Java\ Spring\ Example.zip
b) git repository:
git clone https://github.com/ONLYOFFICE/document-server-integration.git
Change the current directory for the project directory:
a) from archive
cd Java\ Spring\ Example/
b) from git repository
cd document-server-integration/web/documentserver-example/java-spring
Edit the application.properties configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed.
nano src/main/resources/application.properties
Edit the following lines:
files.storage=
server.port=port
files.docservice.url.site=https://documentserver/
where the documentserver is the name of the server with the ONLYOFFICE Docs installed, port is any available port and files.storage is the path where files will be created and stored (in the project folder by default). You can set an absolute path.
Install Maven:
sudo apt-get install maven
Build:
mvn package
./mvnw spring-boot:run
http://server.address:server.port/
In case the example and Document Server are installed on different computers, make sure that your server with the example installed has access to the Document Server with the address which you specify instead of documentserver in the configuration files.
Make sure that the Document Server has access to the server with the example installed with the address which you specify instead of example.com in the configuration files.
Edit the application.properties configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed (installation instructions).
nano src/main/resources/application.properties
Edit the following lines:
files.storage=
server.port=port
files.docservice.url.site=https://documentserver/
where the **documentserver** is the name of the server with the ONLYOFFICE Docs installed, **port** is any available port and **files.storage** is the path where files will be created and stored (in the project folder by default). You can set an absolute path.
Run the next command in the java example directory:
docker-compose up
Open your browser using server.address and server.port:
http://server.address:server.port/
Please keep in mind the following security aspects when you are using test examples: