首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring @Autowired - BeanCreationException

Spring @Autowired - BeanCreationException
EN

Stack Overflow用户
提问于 2016-01-12 08:13:39
回答 1查看 14.9K关注 0票数 6

当我试图在服务器上部署文件时,会发生错误。我很困惑,因为这段代码有效。

异常

代码语言:javascript
复制
    Failed to enable lec2ear-1.0.ear.

Unexpected HTTP response: 500

Request
{
    "address" => [("deployment" => "lecture_7")],
    "operation" => "deploy"
}

Response

Internal Server Error
{
    "outcome" => "failed",
    "failure-description" => {"JBAS014671: Failed services" => {"jboss.undertow.deployment.default-server.default-host./mart-parent" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./mart-parent: Failed to start service
    Caused by: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'storageController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private ru.menkin.ea.lec4.model.services.ICategoryService ru.menkin.ea.lec5.controllers.StorageController._categoryService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'categoryService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private ru.menkin.ea.lec4.model.repositories.CategoryRepository ru.menkin.ea.lec4.model.services.CategoryService.categoryRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'categoryRepository': Cannot resolve reference to bean 'jpaMappingContext' while setting bean property 'mappingContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/recipeDs
Error Code: 0

ICategoryService

代码语言:javascript
复制
public interface ICategoryService
{
    public Category create(Category category);
    public Category delete(int id) throws Exception;
    public List<Category> findAll();
    public Category update(Category category) throws Exception;
    public Category findById(int id);
}

his实现

代码语言:javascript
复制
public class CategoryService implements ICategoryService
{
    @Autowired
    private CategoryRepository categoryRepository;
...

控制器

代码语言:javascript
复制
@Controller
@RequestMapping(value = "/rest")
public class StorageController extends BaseController {
    @Autowired
    @Qualifier("categoryService")
    private ICategoryService _categoryService;
...

database.xml

代码语言:javascript
复制
<djpa:repositories base-package="ru.menkin.ea.lec4.model" />

<bean id="categoryService" class="ru.menkin.ea.lec4.model.services.CategoryService" />

beans.xml

代码语言:javascript
复制
<context:annotation-config />
<context:component-scan base-package="ru.menkin.ea" />

我的错误在哪里?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-01-12 08:27:51

下面是异常消息中的最后一个原因:

代码语言:javascript
复制
Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is javax.persistence.PersistenceException

Spring无法调用jpaMappingContext的init方法,因为出现了持久性异常--数据库中发生了错误。

因此,Spring自动装配实际上是工作的,但是它不能自动处理您的依赖关系,因为初始化一个spring时会发生数据库问题。

因此,数据库或数据库设置中的某些内容自该代码上次工作以来发生了变化。分析整个堆栈跟踪以找出此问题的根源--这是一个数据库问题。

票数 13
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34738498

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档