org.springframework.beans.factory.NoSuchBeanDefinitionException:没有定义名为'com.century.service.SupplierService'的bean

时间:2017-06-22 04:09:42

标签: java spring hibernate spring-mvc javabeans

当我使用应用程序上下文获取我的服务以获取带有名称的bean时,其他包中的所有服务都运行正常,但是world package中的服务会将异常作为标题抛出。

<bean id="txManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>

<bean id="contextHolder" class="com.globalsion.util.spring.ApplicationContextFactory" />

<bean id="hibInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
    <property name="sessionFactory">
        <ref local="sessionFactory" />
    </property>
</bean>

<aop:config>
    <aop:pointcut id="allServiceMethods"
        expression="execution(* 
    com.**.service.**.**(..))" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="allServiceMethods" />
</aop:config>
<aop:config>
    <aop:pointcut id="baseServiceMethods"
        expression="execution(* 
    com.**.service.**.**.**(..))" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="baseServiceMethods" />
</aop:config>
<aop:config>
    <aop:pointcut id="allDaoMethods" expression="execution(* 
    com.**.dao.**.**(..))" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="allDaoMethods" />
</aop:config>
<aop:config>
    <aop:pointcut id="baseDaoMethods"
        expression="execution(* 
    com.**.dao.**.**.**(..))" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="baseDaoMethods" />
</aop:config>
<aop:config>
    <aop:pointcut id="allBeanMethods"
        expression="execution(* 
    com.**.jsf.bean.**.**.**(..))" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="allBeanMethods" />
</aop:config>
<tx:advice id="txAdvice" transaction-manager="txManager">
    <tx:attributes>
        <tx:method name="*" propagation="REQUIRED" />
        <tx:method name="*newTrans" propagation="REQUIRES_NEW" />
        <tx:method name="get*" propagation="NOT_SUPPORTED"
            read-only="true" />
        <tx:method name="find*" propagation="NOT_SUPPORTED"
            read-only="true" />
    </tx:attributes>
</tx:advice>

我的供应商服务界面。

package com.century.service;

import com.century.data.Supplier;
import com.globalsion.service.base.Service;

public interface SupplierService extends Service<Supplier> {

}

我的供应商服务实施。

package com.century.service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.primefaces.model.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.century.dao.SupplierDAO;
import com.century.data.Supplier;

@Service("com.century.service.SupplierService")
public class SupplierServiceImpl implements SupplierService {
    @Autowired
    private SupplierDAO classDAO;

    public SupplierDAO getClassDAO() {
        return classDAO;
    }

    public void setClassDAO(SupplierDAO classDAO) {
        this.classDAO = classDAO;
    }

    // My other irrelevant methods
}

我在com库存服务包中的条形码服务工作正常。

package com.inventory.service;

import com.inventory.data.Barcode;
import com.globalsion.service.base.Service;

public interface BarcodeService extends Service<Barcode>{

}

我的条形码服务impl。

package com.inventory.service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.primefaces.model.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.globalsion.dao.AutoNumberDAO;
import com.inventory.dao.BarcodeDAO;
import com.inventory.data.Barcode;

@Service("com.inventory.service.BarcodeService")
public class BarcodeServiceImpl implements BarcodeService {
    @Autowired
    private BarcodeDAO classDAO;
    @Autowired
    private AutoNumberDAO autoNumberDAO;

    public BarcodeDAO getClassDAO() {
        return classDAO;
    }

    public void setClassDAO(BarcodeDAO classDAO) {
        this.classDAO = classDAO;
    }

    public AutoNumberDAO getAutoNumberDAO() {
        return autoNumberDAO;
    }

    public void setAutoNumberDAO(AutoNumberDAO autoNumberDAO) {
        this.autoNumberDAO = autoNumberDAO;
    }

    // My other irrelevant methods
}

任何人都知道我的代码有什么问题?感谢。

0 个答案:

没有答案