ProcessBuilder的構(gòu)造函數(shù)接受一個(gè)命令,每個(gè)后續(xù)的 String 都被視為第一個(gè) String 的參數(shù),被識別為主命令。嘗試更換/bin/bash用pandoc,看看它是否工作。在我這邊,我可以在沒有 ProcessBuilder 幫助的情況下運(yùn)行任意命令,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); }}獲得預(yù)期輸出: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方式來實(shí)現(xiàn):Process proc = new ProcessBuilder("ipconfig").start();只需調(diào)用您要運(yùn)行的命令即可。我有來自 spring 框架的以下 bean xml。現(xiàn)在我們正在使用所有注釋轉(zhuǎn)移到 spring boot。如何將以下 bean 轉(zhuǎn)換為注釋?<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(是其他一些庫)
添加回答
舉報(bào)
0/150
提交
取消