依赖
<dependency>
<groupId>com.artofsolving</groupId>
<artifactId>jodconverter</artifactId>
<version>2.2.1</version>
</dependency>
失败原因
搜索了很多OpenOffice的启动方法都是这样:
soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard &
但他们都没说这只能本地连接,想要远程连接需要把host=127.0.0.1修改为host=0.0.0.0,这样才能远程连接。
测试代码
@SpringBootTest
public class OpenOfficeApplicationTest {
private SocketOpenOfficeConnection connection;
@BeforeEach
public void socketOpenOfficeConnection(){
connection = new SocketOpenOfficeConnection("1.14.102.121", 8100);
}
@Test
public void testConnection() {
try{
connection.connect();
System.out.println("连接成功");
}catch (Exception e){
System.out.println("连接失败");
e.printStackTrace();
}
}
}