-
3 votesanswersviews
为什么我们需要在spring-boot-starter-jersey项目中为Jersey资源提供@Component spring注释?
这个问题与样本有关:https://github.com/spring-projects/spring-boot/blob/master/spring-boot-samples/spring-boot-sample-jersey/src/main/java/sample/jersey/Endpoint.java 使用spring-boot -starter-jersey项目时,为什么我们需要Jer... -
0 votesanswersviews
Spring @Scheduled注释和Singleton类
我已经创建了一个具有默认(Singleton)范围的类的bean . 在课堂上我有一个计划每小时运行一次的方法 . public class TaskService implements InitializingBean { @Scheduled(cron="0 0 */1 * * ?") public void hourlyReportTask() ... -
2 votesanswersviews
ehcache spring方法缓存除非不起作用
在我的项目(Java Spring 3.2)中,我有一个用 @Cacheable 注释装饰的方法,我正在使用ehcache . 缓存工作正常,除非装饰代码抛出异常 @Override @Cacheable(value = "fooById", key = "'idFoo ' + #idFoo" , unless="#result == null&... -
-1 votesanswersviews
@cacheable spring for redis,方法具体ttl?
我想使用redis来缓存我的远程服务请求:响应键:使用@Cacheable注释的值对 我知道redis为我提供了具有密钥特定到期时间的功能 . 在@Cacheable中是否有任何规定允许我使用此redis功能 . 理想情况下,“ttl”应该是@Cacheable注释的属性,但由于并非所有高速缓存都支持特定于键的ttl,因此spring可能没有包含ttl属性 . 据我所知,spring建议使用不同的... -
0 votesanswersviews
@Cacheable [Spring MVC]无法正常工作
我的 Spring 季项目有一个 jar 包装 . 我在我的资源文件夹中使用Spring 4.3.2 . 我有一个基于xml的配置文件:abc-servlet-context.xml <?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns:mvc="http://www.... -
23 votesanswersviews
带有2个事务管理器的@EnableTransactionManagement注释
我使用 @Configuration 注释来配置spring而不是xml文件 . 我正在配置具有不同会话工厂和不同事务管理器的2个数据源 . 我在这里遇到了 @EnableTransactionManagement 注释的问题 . 我在其文档中读到, @EnableTransactionManagement更灵活;它将回退到容器中任何PlatformTransactionManager bean... -
2 votesanswersviews
Spring是否支持跨多个属性文件的嵌套属性?
我想在多个文件之间分隔属性,并允许稍后加载的文件具有引用或组合先前定义的属性(嵌套)的属性 . 例如: application.properties(例如dbName = test,dbHost = targethost)mysql.properties(例如jdbcDriver = com.mysql.jdbc.Driver,jdbcUrl = jdbc:mysql:// $ {dbHost:l... -
2 votesanswersviews
为什么我的@Cachable注释方法不会使用EHCache缓存结果?
我在Spring中有一个拦截器,它可以自动连接两个不同的服务 . 这两个服务都有从ehcache-spring-annotations项目用 @Cacheable 标记的方法,但是使用不同的 cacheNames . public class MenuInterceptor extends HandlerInterceptorAdapter { @Autowired privat... -
301 votesanswersviews
带有点( . )的Spring MVC @PathVariable正在被截断
这是问题的延续Spring MVC @PathVariable getting truncated Spring论坛声明它已修复(3.2版本)作为ContentNegotiationManager的一部分 . 见下面的链接 .https://jira.springsource.org/browse/SPR-6164https://jira.springsource.org/browse/SPR-7... -
0 votesanswersviews
Struts2和Spring错误:没有为依赖项找到类型的限定bean
我的项目使用Spring 3.2和Struts2(都使用注释) . 我正在通过Java配置Spring . 当我尝试将一个服务注入一个动作时,我从Struts2得到以下错误: 找不到[com.ceiwc.mvc.service.IUserService]类型的限定bean用于依赖:预期至少有1个bean有资格作为此依赖项的autowire候选者 . 依赖注释:{@ org.springframe... -
66 votesanswersviews
如何在web.xml中注册Spring @Configuration带注释的类而不是applicationContext.xml文件?
我在web应用程序中一起使用jsf和spring . 我已经在一个配置类中配置了数据源和会话工厂,该配置类使用 @Configuration, @ComponentScan 等 I don't have any applicationContext.xml file in my project 之类的注释,因为我正在处理Configuration类中上下文xml的每个条目 . 测试用例成功运行但是... -
0 votesanswersviews
Spring 3.1 Cache Annotation EhCache
我目前正在使用Spring 3.1 Cache使用EhCache来实现方法缓存 . 考虑下面的代码片段: @Cacheable("items") public Item findByPK(int itemID) { String sql = "SELECT * FROM ITEM WHERE ITEM_ID = ?"; Item item =... -
1 votesanswersviews
缓存不起作用 - Ehcache Spring注释
我是Ehcache的新手 . 我尝试了一个Spring和Ehcache的例子 . 缓存似乎不起作用 . 当我尝试调试时,服务层返回对象但它没有被缓存 . 缓存中的键为空 . 以下是我的代码: web.xml中 <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class&g... -
0 votesanswersviews
Spring Integration - kafka Outbound适配器不将主题值暴露为spring bean
我已经成功地将kafka outbound channle adapter与固定主题名称集成在一起 . 现在,我想让主题名称可配置,因此,希望通过应用程序属性公开它 . application.properties包含以下条目之一: kafkaTopic:testNewTopic 我的配置类如下所示: @Configuration @Component public class KafkaCon... -
0 votesanswersviews
使用Spring Data Cassandra将MapOf - UserDefinedType映射到cassandra中的POJO
我在cassandra中有以下用户定义的类型: CREATE TYPE key( name text, created_time timestamp ); 它如下表所示: CREATE TABLE keys( id uuid, keys map<text, frozen<list<key>>> ); 请注意,下面的POJOS还... -
145 votesanswersviews
在单元测试期间填充Spring @Value
我在我的程序中使用'm trying to write a Unit Test for a simple bean that'来验证表单 . bean使用 @Component 进行批注,并且具有使用 @Value("${this.property.value}") private String thisProperty; 初始化的类变量 我想为这个类中的验证方法编写单元测试... -
3 votesanswersviews
@Cachable注释不起作用
我们在项目中使用ehcache进行缓存 . import com.googlecode.ehcache.annotations.Cacheable; // Other imports @Component public class Authenticator{ @Cacheable(cacheName = "rest_client_authorized") p...