Using @Bean for managed beans


Is it also right practice with CUBA to use the @Bean annotation for managed beans? Particularly I am using it to create a singleton bean from an environment variable I read from Something like:

public class MyConfiguration {


    public Credentials owner() {

        String privateKey = getOwnerPrivateKey();
        Credentials owner = Credentials.create(privateKey);

        return owner;


    public String getOwnerPrivateKey() {
        return AppContext.getProperty("owner.privateKey");

Thank you.


You can choose any method of creating your beans. However, CUBA IntelliJ plugin can have difficulties finding them for its “Inject” dialog.

Thank you Konstantin, will keep it in mind.