jeudi 30 mars 2017

How create spring with random port?

Spring-boot has random port generation as described here. But this example about web configuration. Is there a way to generate random port number, check that it is avalible, and reserve it for bean creation? E.g. something like that:

@Bean
public void myBean (@Value("${somePort}") String port) {
    return new MyBean(port);
}

Please note, that spring has random properties like ${random.int} but this does not garante that port is free to use.




Aucun commentaire:

Enregistrer un commentaire