autowired 相关问题

自动装配是DI容器功能,其中根据某些标准自动查找依赖关系。





如何创建一个春季库,消费者可以自动导入所有豆?

package com.example.demo.service; @Slf4j @Service @RequiredArgsConstructor public final class MyCustomService { ... } package com.example.demo.config; @Configuration @ComponentScan(basePackages = "com.example.demo") public class MyCustomConfig { }

回答 1 投票 0


JpaRepository NPE 在服务中使用时

我正在尝试使用 JPA 存储库。问题是我正在尝试这种方法: @RestController 公共类控制器{ @Autowired 私有存储库存储库; 私人服务...

回答 1 投票 0

Spring Boot 错误@Autowired RestTemplateBuilder 与 junit

尝试使用 RestTemplateBuilder 在 Spring Boot 2.1.4 中 @Autowired RestTemplate。 当我运行 junit 测试时,尝试自动连接 RestTemplate 时出现错误。 我在这里看到:How to autowire RestTe...

回答 2 投票 0

在构造函数 Symfony PHP 中传递接口

我是接口新手,有人可以建议何时在方法中自动装配接口吗,因为接口没有功能,功能来自方法 $logger 中的哪里...

回答 1 投票 0

如何在 Spring 中注入(自动装配)bean 以枚举作为映射键进行映射?

我了解到,在春天,我可以通过配置名称自动装配/注入到Map中,如下所示: 公共接口虚拟接口{ } @Component("impl1") 公共类 Impl1

回答 3 投票 0

无法自动装配 ConfigurationProperties 类

我无法自动装配配置属性类。该实例始终为空。 我关注了这篇文章:https://www.baeldung.com/configuration-properties-in-spring-boot#1-spring-boot-22 春天嘘...

回答 1 投票 0

为什么 Spring 依赖注入 @Autowired 在 servlet 中抛出 NullPointerException?

项目结构: 测试控制器.java: 包 com.mypack; 导入java.io.IOException; 导入 java.io.PrintWriter; 导入 javax.servlet.ServletException; 导入 javax.servlet.annotation.WebServ...

回答 2 投票 0

Spring Security 创建名为“securityConfig”的 bean 时出错:自动装配依赖项注入失败

我正在用JAVA做一个小项目,我使用Spring Security进行身份验证,但是当我尝试运行我的代码时,它给了我以下错误堆栈: org.springframework.beans.factory.

回答 2 投票 0

JAVA + SpringSecurity + 创建名为“securityConfig”的 bean 时出错:自动装配依赖项注入失败

我正在用JAVA做一个小项目,我使用Spring Security进行身份验证,但是当我尝试运行我的代码时,它给了我以下错误堆栈: org.springframework.beans.factory.

回答 0 投票 0

使用字段[重复]时,Spring Boot Autowired 在 Main() 中抛出 NullPointerException

注意:自从我找到解决方案以来,我正在更新此内容。 这个问题类似于 Why is my Spring @Autowired field null? ,但我在这里使用 main() 方法。解决方案是用 @Com 标记 Foo...

回答 1 投票 0

无法分配ServletContext spring 3

我尝试在 Util 类中使用 servletcontext.getRealPath 来加载文件资源(不是单元测试的一部分),但它不起作用。 我尝试两者都使用“implements ServletContextAware”: @Com...

回答 1 投票 0

使用 Symfony autowire 时是否可以排除多个目录?

在 Symfony 4 中使用 autowire 时,我使用了这个工作代码: 应用程序\: 资源:'../src/*' 排除:'../src/{域、实体、迁移、测试}' 该代码从自动装配中排除了所有这些...

回答 3 投票 0

J2EE 应用程序服务器如何服务单个 WebService 调用

在一个项目的编码过程中,我遇到了一个疑问。 正如标题所示,我的疑问是 J2EE 应用程序服务器如何为单个 WebService 调用提供服务。 当客户端调用 WS 时...

回答 1 投票 0

Springboot不创建mapstruct bean

我有一些带有以下代码的映射器: 导入 org.mapstruct.Mapper; 导入 org.mapstruct.MappingConstants; @Mapper(componentModel = MappingConstants.ComponentModel.SPRING) 公共接口

回答 1 投票 0

如果使用缓存,Bean 不会自动装配

在我的应用程序中,如果我使用 @Cacheable 或/和 @CacheEvict 注释,bean 不会自动装配。 我通过排除法得出了这个结论。如果你用 @Cacheable 和 @CacheEvict 注释掉这些行,那么一切......

回答 1 投票 0

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.