简体   繁体   中英

Managed Application scoped bean creates multiple times

I have beans

@ManagedBean(name="HistoryBean")
@ApplicationScoped
public class HistoryBean
{...}

@ManagedBean(name="ViewBean")
@ApplicationScoped
public class ViewBean
{
        public void setHistoryBean(HistoryBean historyBean) 
        {this.historyBean = historyBean;}

    @ManagedProperty(value="#{HistoryBean}")
    private HistoryBean historyBean;
}

I want to HistoryBean was created only once, but it creates on each request(?) with clean state. What did I do wrong?

Trouble was in wrong annotation imports. You need to use annotation which are from javax.faces.bean package.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM