1,application.yml
company:
office:
convertWindowsCmd: ${project.office.convertWindowsCmd}
convertLinuxCmd: ${project.office.convertLinuxCmd}
2,application-dev/other.yml,或直接写在application.yml
project:
office:
convertWindowsCmd: soffice --headless --convert-to pdf $/{inputPath} --outdir $/{outDir}
convertLinuxCmd: libreoffice --convert-to pdf:writer_pdf_Export $/{inputPath} --outdir $/{outDir}
3,获取自定义配置
@Component("libreOfficeUtils")
public class LibreOfficeUtils {
@Value("${company.office.convertWindowsCmd}")
private String convertWindowsCmd;
@Value("${company.office.convertLinuxCmd}")
private String convertLinuxCmd;
private static final Logger log = LoggerFactory.getLogger(LibreOfficeUtils.class)