我使用 Spring + Ehcache 作为我的缓存层。(通过代理)
我想知道您是否可以在同一个缓存中同时缓存“findAll”结果和“findById”结果,然后 CacheEvict 特定项目和“findAll”结果(保持项目的其余部分不变)并在更新时将其加载回来再次缓存“findById”时?
(或另一种方法是将 findAll 和 findById 保留在 2 个缓存中,并在为 findAll 缓存和 findById 缓存上的特定项目更新 CacheEvict allEntries 时)
这可能吗?
我使用spring + struts2,我有大量需要单个服务(mailService)的动作类.我想知道有没有办法创建父类并注入资源,然后让所有这些类扩展父类,而不是将服务注入这些操作类.所以我不需要在每节课中重复注射.
提前致谢
我没有写单元或集成测试,但现在我正在尝试.我很难设置环境.
我在WEB-INF/applicationContext*.xml下有我的应用程序上下文,在我的applicationContext.xml中,它有一个对DB用户/传递,LDAP主机等的属性文件的引用
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>/WEB-INF/spring-config/dev.properties</value>
</list>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
我有另一个log4j配置属性(DEV/Staging/Production的diff配置).${webapp.root}在web.xml中定义
<!-- log4j setting -->
<bean id="log4jInitialization" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetClass" value="org.springframework.util.Log4jConfigurer" />
<property name="targetMethod" value="initLogging" />
<property name="arguments">
<list>
<value>${webapp.root}/${log4j.properties.location}</value>
</list>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
现在我试图将以下内容放入测试类中.
@Override
protected String[] getConfigLocations() {
return new String[]{
"file:trunk/code/web/WEB-INF/applicationContext.xml",
};
}
Run Code Online (Sandbox Code Playgroud)
这正确引用了我的xml,但所有属性都被搞砸了.
我想知道以下内容:
请指教
谢谢
我们现在正在使用2.x弹簧安全.我被要求构建一个管理工具,以便ROLE_ADMIN可以更改为站点中的任何用户并以该人员的身份查看站点(站点上的每个人可能会看到不同的东西,具体取决于基于数据库动态授予的角色)当然,管理员应该能够在不登录的情况下切换回管理员.
是否有内置功能,如果不是我应该怎么做?
提前致谢!
我试图将数据源对象注入servlet.我有使用set方法打印的记录器.它适用于pre-inialization.但是当我请求servlet时,它给了我nullPointerException.
为什么会发生这种情况的任何建议?(我不认为这与我正在扩展的servlet有关)
这是applicationContext.xml
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
<bean id="dataServlet" class="com.mycom.util.DataServlet">
<property name="dataSource" ref="dataSource" />
<property name="test" value="dataSource" />
</bean>
Run Code Online (Sandbox Code Playgroud)
servlet
public class DataServlet extends DataSourceServlet {
...
@Autowired
public void setDataSource(DataSource dataSource) {
this.jdbcTemplate = new JdbcTemplate(dataSource);
logger.log(Level.INFO, "Inj: datasrc");
}
@Autowired
public void setTest(String test) {
this.test = test;
logger.log(Level.INFO, "Set Test {0}", this.test);
}
}
Run Code Online (Sandbox Code Playgroud)
我在setTest设置了断点,它打破了@ pre-init.但是当实际对象被请求时.它不会破坏@testTest.
为什么会这样?(单例/范围问题有关吗?)
请指教!提前致谢!