83得票4回答
Spring可以在抽象类中自动装配吗?

Spring不能自动装配我的对象?在抽象类中是否可以自动装配对象。假设所有模式都在application-context.xml中提供。问题:基本类和扩展类(如果有的话)应该使用什么注解@Service @Component?示例abstract class SuperMan { @...

8得票2回答
Spring框架如何自动装配集合类型

我从未见过一个自动装配的集合: @Service public class SomeFactory { @Autowired private List<Foo> foos; @PostConstruct public void init() { ...

9得票2回答
再次提问:使用Spring Boot/Security实现方法级安全时出现错误:“创建名为'methodSecurityInterceptor'的bean时出错,该对象已经被构建。”

我希望实现方法安全性。 我在使用@Secured和@PreAuth注释时遇到了问题。每当我将它们添加到我的服务接口中时,就会收到以下异常。没有它们,我的应用程序可以正常运行。 Caused by: org.springframework.beans.factory.BeanCreation...

59得票8回答
找不到类型匹配的bean以满足依赖关系

经过几天的尝试和等待Springsource论坛的答案后,我来到这里试试。 运行我的应用程序会导致以下异常:org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [co...

32得票3回答
如何模拟一个Spring bean的自动装配列表?

我已经阅读了很多关于如何模拟Spring的bean及其自动装配字段的文章,但是我找不到有关自动装配bean列表的任何信息。 具体问题 我有一个名为FormValidatorManager的类。这个类循环遍历实现了IFormValidator接口的多个验证器。@Component publi...

38得票2回答
自动装配在Servlet中的应用

我希望在servlet中使用Spring自动装配,这是我的代码:@Configurable public class ImageServlet extends HttpServlet { @Autowired private SystemPropertyDao systemPro...

59得票5回答
@Autowired注入的Environment为空。

我在连接环境到我的Spring项目时遇到了问题。 在这个类中@Configuration @ComponentScan(basePackages = "my.pack.offer.*") @PropertySource("classpath:OfferService.properties") ...

9得票4回答
忽略一个被@Autowired注入的目录中的类

我在我的service/文件夹里遇到了一个异常,并且Symfony正在尝试进行自动装配: 无法进行自动装配服务 "App\Service\Order\Exception\StripeRequiresActionException":方法“__construct()”的参数“$secre...

351得票3回答
理解Spring中@Autowired的用法

我正在阅读Spring 3.0.x参考文档,以了解Spring Autowired注释: 3.9.2 @Autowired和@Inject 我不理解以下示例。我们需要在XML中做些什么才能使其工作? 示例1:public class SimpleMovieLister { pr...

12得票3回答
如何在Spring中更新@Autowired String Bean的值?

我有一个字符串作为bean自动装配。这个 String 的值是通过属性文件设置的,并在运行时加载。我可以验证到这一点。以下是我的XML:<context:property-placeholder location="classpath:my-app.properties" /> ...