我从spring-boot开始,我有一些配置问题。我无法自动操作某些服务。我得到一个BeanCreationException。
@SpringBootApplication
@EnableAutoConfiguration
@ComponentScan(basePackages = "com.x.server", basePackageClasses = { OAuth2ServerConfiguration.class,
AController.class, BController.class })
public class Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) {
new Application().configure(new SpringApplicationBuilder(Application.class)).run(args);
}
}
----com.x.server
--------Application.java
----com.x.server.controller
--------AController.java
--------BController.java
----other packages
----com.x.server.service
--------WYXService
--------ABCService
----com.x.server.service.serviceImpl
--------WYXServiceImpl
--------ABCServiceImpl
public interface WYXService<T> {
public void setClazz(final Class<T> clazzToSet);
public void createEntity(T t);
public void removeEntity(T t);
}
@Transactional
@Service("wyxService")
public class WYXServiceImpl<T> implements WYXService<T>
Hier是我自动执行服务的控制器:
@Path("/test")
@Component
@Controller
@Produces(MediaType.APPLICATION_JSON)
public class BController {
@Autowired
WYXService wyxService;
控制台的错误:
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.x.server.service.WYXService com.x.server.controller.BController.wyxService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.x.server.service.WYXService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:561)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
... 25 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.x.server.service.WYXService ] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1301)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1047)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:533)
... 27 more
当我从compenentscan中删除两个控制器时,我不会出现这个错误,但我需要扫描这些控制器来访问endpoint。
我删除泽西依赖项:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
然后添加了sprint-boot-starter-web依赖项
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
我正在使用java配置而不是XML迁移到spring Security4.0.1。当我自动操作时,它会给出以下错误: HTTP状态500-org.springframework.beans.factory.beanCreationException:创建名为“ScopedTarget.UsersComponent”的bean时出错:注入autowired依赖项失败;嵌套异常为org.springf
我的类使用@service,而bean已经自动连线,所以我不明白为什么会出现这个错误。
这是我的当前设置:ProjectRepo: ProjectService: ProjectRestController:
我正在学习将activiti与spring boot结合使用,但我遇到了一些错误,并且搜索了太多关于使用spring boot和java的acitiviti稳定版本的信息 我正在使用java 8和tomcat 8.0.3 我更改了这么多版本的spring和jdk,检查了这么多样本,没有发现任何问题,我只有一个控制器类和spring主类,当我运行项目时,得到了以下错误: 这是我的RestContro
我在我的服务器Tomcat上部署project后遇到了这个错误。我发现了许多类似的问题,但我没有找到我的问题的答案。 ApplicationContext.xml CategoryDaoDbImpl类 Category类
我试图在没有任何实现的情况下使用Spring Data JPA-Crudepository use(所有默认选项)。 我的代码有这个例外: 线程“main”组织中出现异常。springframework。豆。工厂BeanCreationException:创建名为“springJpaContactService”的bean时出错:自动连线依赖项的注入失败;嵌套的异常是org。springframe