Spring getActiveProfiles();始终为空
我在xhtml中有一个页面,我不想在生产环境中呈现这个页面,所以我用面板包装了页面上的所有元素Spring getActiveProfiles();始终为空,spring,environment-variables,spring-profiles,Spring,Environment Variables,Spring Profiles,我在xhtml中有一个页面,我不想在生产环境中呈现这个页面,所以我用面板包装了页面上的所有元素 <p:panel id="main" rendered="#{swaggerBean.activeProfiles}" > 尝试进入页面后,第行出现空指针异常: String[] activeProfiles = environment.getActiveProfiles(); 我还尝试通过@ManagedProperty注入环境,但结果是一样的
<p:panel id="main" rendered="#{swaggerBean.activeProfiles}" >
尝试进入页面后,第行出现空指针异常:
String[] activeProfiles = environment.getActiveProfiles();
我还尝试通过@ManagedProperty注入环境,但结果是一样的
@ManagedProperty(value="#{environment}")
private Environment environment;
您知道如何避免@ManagedBean上的空指针吗?
我尝试了使用EnvironmentAware的解决方案,但仍然存在NPE,或者可能有更好的方法禁用我的生产页面?用@Component而不是@ManagedBean注释SwaggerBean
@ManagedProperty(value="#{environment}")
private Environment environment;