New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloud config and SpEL in @Value #821

Closed
kevinho opened this Issue Oct 13, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@kevinho

kevinho commented Oct 13, 2017

I met a issue,I try to listen to EnvironmentChangeEvent and re-init some configuration, while i found that @value annotation with SpEL is not working, but plain @value annotation is OK:

@Component
public class ConsumeService {

    @Autowired
    ConsumeConfig consumeConfig;

 @EventListener(EnvironmentChangeEvent.class)
    void onEnvChange() {
     log.debug("{}",consumeConfig);

//when i print here, i get only consumeDesc, but cardList is an empty List.
    }
}
@Configuration
@RefreshScope
public class ConsumeConfig {

    @Value("${consume.desc}")
    private String consumeDesc;
    
    @Value("#{'${api.server.round.card}'.split(',')}")
    private List<String> cardList;
}

Question:

Is this issue related with lifecycle of SpEL? It seems that, the value of SpEL is not yet parsed.

@kevinho kevinho changed the title from cloud config and spel to Cloud config and spel in @Value Oct 13, 2017

@kevinho kevinho changed the title from Cloud config and spel in @Value to Cloud config and SpEl in @Value Oct 13, 2017

@kevinho kevinho changed the title from Cloud config and SpEl in @Value to Cloud config and SpEL in @Value Oct 13, 2017

@spencergibb

This comment has been minimized.

Show comment
Hide comment
@spencergibb

spencergibb Oct 20, 2017

Member

We have only ever documented that placeholders ${} work, not SpEL.

Member

spencergibb commented Oct 20, 2017

We have only ever documented that placeholders ${} work, not SpEL.

@kevinho

This comment has been minimized.

Show comment
Hide comment
@kevinho

kevinho Oct 21, 2017

I get it. Hope to support SpEL next.

kevinho commented Oct 21, 2017

I get it. Hope to support SpEL next.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment