猿问

将bean xml转换为spring boot注解

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 Windows



Scheda 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.1


Process finished with exit code 0

如果你真的需要使用ProcessBuilder,同样的行为可以通过定义你的Process方式来实现:


Process proc = new ProcessBuilder("ipconfig").start();

只需调用您要运行的命令即可。我有来自 spring 框架的以下 bean xml。现在我们正在使用所有注释转移到 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(是其他一些库)


元芳怎么了
浏览 367回答 3
3回答
随时随地看视频慕课网APP

相关分类

Java
我要回答