如何在sprintBoot RMI上使用@Lazy

问题描述

在这种情况下,即使我在bean上使用@Lazy,端口号仍为0,而不是1199。 我该如何解决,因为我想在应用程序运行后设置端口号。

@SpringBootApplication
public class startClient {

    private volatile static int portNumber;


    @Bean
    @Lazy
    public  RmiProxyfactorybean rmiProxy() {
        RmiProxyfactorybean bean = new RmiProxyfactorybean();
        bean.setServiceInterface(ChatRoomService.class);
        System.out.println(portNumber);
        bean.setServiceUrl("rmi://localhost:1199/RoomService");
        return bean;
    }



    public static void main(String[] args) {


        SpringApplication app = new SpringApplication(startClient.class);
        app.setHeadless(false);
        ConfigurableApplicationContext context = app.run(args);
        
        portNumber = 1199;

    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)