Spring boot. Injection SpringBean into viewModel.

asked 2019-10-21 22:07:07 +0800

Evgenic gravatar image Evgenic
14 3


zkVersion = 8.6.2; zkspringboot-starter, version: '1.0.4;

I am trying to inject SpringBean into my viewModel:


<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<zk xmlns="http://www.zkoss.org/2005/zul">


public class ClientForm extends Index {

    private AppConfig myConfig;
public void afterCompose(@ContextParam(ContextType.VIEW) Component view) {
    myConfig == null!!!  <<--- always NULL

... }

AppConfig :

@PropertySource(value = "file:props.properties", name = "prp", encoding = "utf8")
@Scope(proxyMode= ScopedProxyMode.TARGET_CLASS)
public class AppConfig {...}

Mostly it is all. But field 'myConfig' is NULL always. What did I wrong?

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-10-22 12:27:21 +0800

cor3000 gravatar image cor3000
4887 2 7
ZK Team

updated 2019-10-22 12:28:01 +0800

ZK's @WireVariable-annotation specifies a VariableResolver, which is wiring by name.

What's missing is, giving your configuration a matching bean id/name:


so that it matches your annotated variable.

private AppConfig myConfig;

Or you can rename your variable to match the automatic bean id assigned by spring.

private AppConfig appConfig;


link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2019-10-21 22:07:07 +0800

Seen: 9 times

Last updated: Oct 22

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More