ProcessBuilder的構造函數接受一個命令,每個后續的 String 都被視為第一個 String 的參數,被識別為主命令。嘗試更換/bin/bash用pandoc,看看它是否工作。在我這邊,我可以在沒有 ProcessBuilder 幫助的情況下運行任意命令,Runtime.getRuntime().exec(...)而是使用,如下所示:public static void main(String[] args) throws Exception { Process proc = Runtime.getRuntime().exec("cmd /c ipconfig"); BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream())); String line = null; while((line = reader.readLine()) != null){ System.out.println(line); }}獲得預期輸出:Configurazione IP di WindowsScheda Ethernet Ethernet: Suffisso DNS specifico per connessione: Indirizzo IPv6 locale rispetto al collegamento . : fe80::fcba:735a:5941:5cdc%11 Indirizzo IPv4. . . . . . . . . . . . : 192.168.0.116 Subnet mask . . . . . . . . . . . . . : 255.255.255.0 Gateway predefinito . . . . . . . . . : 192.168.0.1Process finished with exit code 0如果你真的需要使用ProcessBuilder,同樣的行為可以通過定義你的Process方式來實現:Process proc = new ProcessBuilder("ipconfig").start();只需調用您要運行的命令即可。我有來自 spring 框架的以下 bean xml?,F在我們正在使用所有注釋轉移到 spring boot。如何將以下 bean 轉換為注釋?<bean id="testPool" class="com.v1.testPoolImpl" init-method="init" destroy-method="shutdown"> <property name="configurations"> <bean class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="location" value="classpath:database.properties"/> </bean> </property></bean>com.v1.testPoolImpl(是其他一些庫)
添加回答
舉報
0/150
提交
取消
