Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试在 Spring 中配置一个 Scanner bean,我认为它会接近:
<bean id="input" class="java.util.Scanner"> <constructor-arg type="InputStream"><value>java.lang.System.in</value></constructor-arg> </bean>
我想知道是否有办法做到这一点?如果不是,请您提供一个理由。
我不确定,你想从中获得什么,
您可以创建一个 InputStream spring bean,
<bean id="stream" class="java.io.InputStream"> <bean id="input" class="java.util.Scanner"> <constructor-arg index="0"><ref bean="stream"/></constructor-arg> </bean>