gpt4 book ai didi

java - 我收到 BeanFactory 错误 : NoSuchBeanDefinitionException and I can't figure out how to solve it

转载 作者:太空宇宙 更新时间:2023-11-04 10:50:02 25 4
gpt4 key购买 nike

我接到的任务是开发现有的 AngularJS SPA(应用程序 B)。此应用程序使用另一个应用程序(应用程序 B)中的代码从数据库获取信息。两个都;应用程序 A 和应用程序 B 使用相同的数据库。目标是修改应用程序 B 以从不同的数据库获取客户、位置和 jetty 。我的目标是仍然使用应用程序 A 使用的一些相同代码,并为应用程序 B 创建新代码,然后访问新数据库以获取信息。

当我尝试启动应用程序 (Eclipse Oxigen) 时,BeanFactory 抛出异常。

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'contextServiceImpl': Unsatisfied dependency expressed through field 'customersRepo'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.csoln.lv.data.cld.dao.CustomersRepo' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

我怀疑 Spring Context 中没有定义该 bean,但我不知道如何定义它。我已经尝试过其他帖子中的建议,但没有任何效果。接下来我将发布代码和相关文件...

请记住,我对 Spring、REStful 服务等还很陌生。我希望你能帮助我解决这个错误。预先感谢您。

服务文件

package com.csoln.lv.service;

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

import com.csoln.lv.cld.bo.CustomerBo;
import com.csoln.lv.cld.bo.DockBo;
import com.csoln.lv.cld.bo.LocationBo;

public interface ContextService {

public List<CustomerBo> getCustomersFiltered();
public Map<String, CustomerBo> getCustomerMapFiltered();
public CustomerBo getCustomer(Integer id);
public List<CustomerBo> getAllCustomers();
public List<CustomerBo> getCustomers();
public Map<String, CustomerBo> getCustomerMap();
public Map<Integer, CustomerBo> getCustomerMapById();

public List<LocationBo> getLocationsFiltered(CustomerBo customer);
public Map<String, LocationBo> getLocationMapFiltered(CustomerBo customer);
public Map<Integer, LocationBo> getLocationMapByIdFiltered(CustomerBo customer);
public LocationBo getLocation(Integer customerId, Integer id);
public List<LocationBo> getAllLocations(CustomerBo customer);
public List<LocationBo> getLocations(CustomerBo customer);

public List<DockBo> getDocksFiltered(LocationBo location);
public Map<String, DockBo> getDockMapFiltered(LocationBo location);
public Map<Integer, DockBo> getDockMapByIdFiltered(LocationBo location);
public DockBo getDock(Integer customerId, Integer locationId, Integer id);
public List<DockBo> getAllDocks(LocationBo location);
public List<DockBo> getDocks(LocationBo location);

public List<DockBo> getSubDocks(DockBo dock);
public Map<String, DockBo> getSubDockMap(DockBo dock);
public Map<Integer, DockBo> getSubDockMapById(DockBo dock);
}
<小时/>

服务实现

package com.csoln.lv.service;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

// For Liveview
import com.csoln.lv.cld.bo.CustomerBo;
import com.csoln.lv.cld.bo.DockBo;
import com.csoln.lv.cld.bo.LocationBo;
import com.csoln.lv.data.cld.dao.CustomersRepo;
import com.csoln.lv.data.cld.dao.DocksRepo;
import com.csoln.lv.data.cld.dao.LocationsRepo;
import com.csoln.lv.data.dom.Customers;
import com.csoln.lv.data.dom.Docks;
import com.csoln.lv.data.dom.Locations;
import com.csoln.lv.data.id.DockId;
import com.csoln.lv.data.id.LocationId;

@Service
@SuppressWarnings("unchecked")
public class ContextServiceImpl implements ContextService {

private static Logger log = Logger.getLogger(ContextServiceImpl.class);

@Autowired
private CustomersRepo customersRepo;
@Autowired
private LocationsRepo locationsRepo;
@Autowired
private DocksRepo docksRepo;

private String customerPrefix = "C_";
private String locationPrefix = "L_";
private String dockPrefix = "D_";

/* (non-Javadoc)
* @see com.csoln.service.data.ContextService#getCustomers()
*/
@Override
public List<CustomerBo> getCustomersFiltered() {
List<String> filter = this.getGrantedAuthorities(this.customerPrefix);
List<CustomerBo> customers = new ArrayList<>();
List<CustomerBo> clients = this.getCustomers(true);
if( clients != null && filter != null && clients.size() > 0 && filter.size() > 0 ) {
Stream<CustomerBo> stream = clients.stream().filter( entry -> filter.contains(entry.getId().toString()));
customers = stream.collect(Collectors.toList());
}
if( log.isDebugEnabled() ) {
log.debug(clients);
}
return customers;
}

/* (non-Javadoc)
* @see com.csoln.service.data.ContextService#getCustomerMap()
*/
@Override
public Map<String, CustomerBo> getCustomerMapFiltered() {
List<CustomerBo> customers = this.getCustomersFiltered();
Map<String, CustomerBo> clients = new HashMap<>();
if( customers != null && customers.size() > 0 ) {
customers.forEach(c -> clients.put(c.getAbbreviation(), c));
}
if( log.isDebugEnabled() ) {
log.debug(clients);
}
return clients;
}

/* (non-Javadoc)
* @see com.csoln.service.ContextService#getCustomer(java.lang.Integer)
*/
@Override
public CustomerBo getCustomer(Integer id) {
return new CustomerBo().toBo(this.customersRepo.findOne(id));
}

/* (non-Javadoc)
* @see com.csoln.service.ContextService#getCustomers()
*/
@Override
public List<CustomerBo> getAllCustomers() {
List<CustomerBo> customers = this.getCustomers(false);
return customers;
}

@Override
public List<CustomerBo> getCustomers() {
List<CustomerBo> customers = this.getCustomers(true);
return customers;
}

private List<CustomerBo> getCustomers(Boolean active) {
Example<Customers> example = null;
List<Customers> entities = null;
if( active ) {
Customers probe = new Customers();
probe.setActiveEntry(active);
example = Example.of(probe);
entities = this.customersRepo.findAll(example, new Sort(Direction.ASC, "shortName"));
} else {
entities = this.customersRepo.findAll(new Sort(Direction.ASC, "shortName"));
}

List<CustomerBo> customers = new ArrayList<>();
if( entities != null && entities.size() > 0 ) {
entities.forEach(c -> {
customers.add(new CustomerBo().toBo(c));
});
}
return customers;
}

/* (non-Javadoc)
* @see com.csoln.service.data.ContextService#getCustomerMapById()
*/
public Map<Integer, CustomerBo> getCustomerMapById() {
SortedMap<Integer, CustomerBo> clients = new TreeMap<>();
List<CustomerBo> customers = this.getAllCustomers();
if( customers != null && !customers.isEmpty() ) {
customers.forEach(c -> clients.put(c.getId(), c) );
}
if( log.isDebugEnabled() ) {
log.debug(clients);
}
return clients;
}

/* (non-Javadoc)
* @see com.csoln.service.data.ContextService#getCustomerMapByAbbreviation()
*/
@Override
public Map<String, CustomerBo> getCustomerMap() {
SortedMap<String, CustomerBo> clients = new TreeMap<>();
List<CustomerBo> customers = this.getAllCustomers();
if( customers != null && !customers.isEmpty() ) {
customers.forEach(c -> clients.put(c.getAbbreviation(), c));
}
if( log.isDebugEnabled() ) {
log.debug(clients);
}
return clients;
}



/* (non-Javadoc)
* @see com.csoln.service.data.ContextService#getLocations(com.csoln.web.bean.CustomerBean)
*/
@Override
public List<LocationBo> getLocationsFiltered(CustomerBo customer) {
List<String> filter = this.getGrantedAuthorities(this.locationPrefix + customer.getId() + "_");
List<LocationBo> locations = new ArrayList<>();
List<LocationBo> ls = this.getLocations(customer);
if( ls != null && !ls.isEmpty() ) {
locations = ls.stream().filter( l-> filter.contains(l.getId().toString())).collect(Collectors.toList());
Collections.sort(locations, (l1, l2) -> (l1.getId() < l2.getId())?1:0);
}
if( log.isDebugEnabled() ) {

}
return locations;
}

/* (non-Javadoc)
* @see com.csoln.service.data.ContextService#getLocationMap(com.csoln.web.bean.CustomerBean)
*/
@Override
public Map<String, LocationBo> getLocationMapFiltered(CustomerBo customer) {
Map<String, LocationBo> locations = new TreeMap<>();
List<LocationBo> locs = this.getLocationsFiltered(customer);
if( locs != null && !locs.isEmpty() ) {
locs.forEach(l -> locations.put(l.getAbbreviation(), l));
}
log.debug(locations);
return locations;
}

/* (non-Javadoc)
* @see com.csoln.service.data.ContextService#getLocationMapById(com.csoln.web.bean.CustomerBean, java.lang.String)
*/
@Override
public Map<Integer, LocationBo> getLocationMapByIdFiltered(CustomerBo customer) {
Map<Integer, LocationBo> locations = new TreeMap<>();
List<LocationBo> locs = this.getLocationsFiltered(customer);
if( locs != null && !locs.isEmpty() ) {
locs.forEach(l -> locations.put(l.getId(), l));
}
log.debug(locations);
return locations;
}

@Override
public LocationBo getLocation(Integer customerId, Integer id) {
LocationId locId = new LocationId(customerId, id);
return new LocationBo().toBo(this.locationsRepo.findOne(locId));
}

/* (non-Javadoc)
* @see com.csoln.service.ContextService#getLocations(com.csoln.common.bo.CustomerBo)
*/
@Override
// @Cacheable(cacheNames = "context", key="#root.target+#root.methodName+#customer")
public List<LocationBo> getAllLocations(CustomerBo customer) {
List<LocationBo> locations = this.getLocations(customer, false);
return locations;
}

@Override
public List<LocationBo> getLocations(CustomerBo customer) {
List<LocationBo> locations = this.getLocations(customer, true);
return locations;
}

private List<LocationBo> getLocations(CustomerBo customer, Boolean active) {
Locations probe = new Locations(customer.getId());
if( active ) {
probe.setActiveEntry(active);
}
List<Locations> entities = this.locationsRepo.findAll(Example.of(probe), new Sort(Direction.ASC, "shortName"));
List<LocationBo> locations = new ArrayList<>();
if( entities != null && entities.size() > 0 ) {
entities.forEach( l->{
locations.add(new LocationBo().toBo(l));
});
}
return locations;
}

/* (non-Javadoc)
* @see com.csoln.service.data.ContextService#getDocks(com.csoln.web.bean.LocationBean)
*/
@Override
public List<DockBo> getDocksFiltered(LocationBo location) {
List<String> filter = this.getGrantedAuthorities(this.dockPrefix + location.getCustomerId() + "_" + location.getId() + "_");

List<DockBo> docs = this.getDocks(location);

List<DockBo> docks = new ArrayList<>();
if( docs != null && filter != null && !docs.isEmpty() ) {
docks = docs.stream().filter( d-> filter.contains(d.getId().toString())).collect(Collectors.toList());
Collections.sort(docks, (d1, d2) -> (d1.getId() < d2.getId())?1:0);
}

if( log.isDebugEnabled() ) {
log.debug(docks);
}
return docks;
}

/* (non-Javadoc)
* @see com.csoln.service.data.ContextService#getDockMap(com.csoln.web.bean.LocationBean)
*/
@Override
public Map<String, DockBo> getDockMapFiltered(LocationBo location) {
Map<String, DockBo> docks = new TreeMap<>();
List<DockBo> dcks = this.getDocksFiltered(location);
if( dcks != null & !dcks.isEmpty() ) {
dcks.forEach(d -> docks.put(d.getAbbreviation(), d));
}
if( log.isDebugEnabled() ) {
log.debug(docks);
}
return docks;
}

/* (non-Javadoc)
* @see com.csoln.service.data.ContextService#getDockMapById(com.csoln.web.bean.LocationBean, java.lang.String)
*/
@Override
public Map<Integer, DockBo> getDockMapByIdFiltered(LocationBo location) {
Map<Integer, DockBo> docks = new TreeMap<>();
List<DockBo> dcks = this.getDocksFiltered(location);
if( dcks != null & !dcks.isEmpty() ) {
dcks.forEach(d -> docks.put(d.getId(), d));
}
if( log.isDebugEnabled() ) {
log.debug(docks);
}
return docks;
}

@Override
public DockBo getDock(Integer customerId, Integer locationId, Integer id) {
DockId dockId = new DockId(customerId, locationId, id);
return new DockBo().toBo(this.docksRepo.findOne(dockId));
}

/* (non-Javadoc)
* @see com.csoln.service.ContextService#getDocks(com.csoln.common.bo.LocationBo)
*/
@Override
// @Cacheable(cacheNames = "context", key="#root.target+#root.methodName+#location")
public List<DockBo> getAllDocks(LocationBo location) {
List<DockBo> docks = this.getDocksIfActive(location.getCustomerId(), location.getId(), false);
return docks;
}

@Override
public List<DockBo> getDocks(LocationBo location) {
List<DockBo> docks = this.getDocksIfActive(location.getCustomerId(), location.getId(), true);
return docks;
}

private List<DockBo> getDocksIfActive(Integer customerId, Integer locationId, Boolean active) {
List<DockBo> docks = new ArrayList<>();
List<Docks> entities = null;
Docks probe = new Docks(customerId, locationId);
if( active ) {
probe.setActiveEntry(active);
}
entities = this.docksRepo.findAll(Example.of(probe), new Sort(Direction.ASC, "shortName"));
List<DockBo> subdocks = new ArrayList<>();
if( entities != null && entities.size() > 0 ) {
entities.forEach( d-> {
subdocks.addAll(getSubDocks(new DockBo().toBo(d)));
docks.add(new DockBo().toBo(d));
});
}
subdocks.forEach(sd -> {
docks.remove(sd);
});
return docks;
}

/* (non-Javadoc)
* @see com.csoln.service.data.ContextService#getSubDocks(com.csoln.web.bean.DockBean)
*/
@Override
// @Cacheable(cacheNames = "context", key="#root.target+#root.methodName+#dock")
public List<DockBo> getSubDocks(DockBo dock) {
List<DockBo> docks = new ArrayList<>();
List<Docks> dcs = this.docksRepo.findSubDocksForDock(dock.getCustomerId(), dock.getLocationId(), dock.getId());
if( dcs != null ) {
dcs.forEach(d ->docks.add(new DockBo().toBo(d)));
}
return docks;
}

/* (non-Javadoc)
* @see com.csoln.service.data.ContextService#getSubDockMap(com.csoln.web.bean.DockBean)
*/
@Override
public Map<String, DockBo> getSubDockMap(DockBo dock) {
Map<String, DockBo> docks = new TreeMap<>();
List<DockBo> dcs = this.getSubDocks(dock);
if( dcs != null ) {
dcs.forEach(d ->docks.put(d.getAbbreviation(), d));
}
return docks;
}

/* (non-Javadoc)
* @see com.csoln.service.data.ContextService#getSubDockMapById(com.csoln.web.bean.DockBean, java.lang.String)
*/
@Override
public Map<Integer, DockBo> getSubDockMapById(DockBo dock) {
Map<Integer, DockBo> docks = new TreeMap<>();
List<DockBo> dcs = this.getSubDocks(dock);
if( dcs != null ) {
dcs.forEach(d ->docks.put(d.getId(), d));
}
return docks;
}

private List<String> getGrantedAuthorities(String prefix) {
List<String> filter = new ArrayList<>();
Collection<SimpleGrantedAuthority> authorities = (Collection<SimpleGrantedAuthority>) SecurityContextHolder.getContext().getAuthentication().getAuthorities();
Stream<SimpleGrantedAuthority> filtered = authorities.stream().filter(a -> a.getAuthority().startsWith(prefix));
filtered.forEach(a -> filter.add(a.getAuthority().replace(prefix, "")));
log.debug("Filtered by User: " + filter);
return filter;
}

/**
* @return the customerPrefix
*/
public String getCustomerPrefix() {
return customerPrefix;
}

/**
* @param customerPrefix the customerPrefix to set
*/
public void setCustomerPrefix(String customerPrefix) {
this.customerPrefix = customerPrefix;
}

/**
* @return the locationPrefix
*/
public String getLocationPrefix() {
return locationPrefix;
}

/**
* @param locationPrefix the locationPrefix to set
*/
public void setLocationPrefix(String locationPrefix) {
this.locationPrefix = locationPrefix;
}

/**
* @return the dockPrefix
*/
public String getDockPrefix() {
return dockPrefix;
}

/**
* @param dockPrefix the dockPrefix to set
*/
public void setDockPrefix(String dockPrefix) {
this.dockPrefix = dockPrefix;
}
}
<小时/>

package com.csoln.lv.data.cld.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.csoln.lv.data.dom.Customers;
import com.csoln.data.repository.SyncRepository;

public interface CustomersRepo extends JpaRepository<Customers, Integer>, SyncRepository<Customers> {

public List<Customers> findByAbbreviationAndActiveEntryTrue(String abbreviation);
public List<Customers> findByIdInAndActiveEntryTrue(List<Integer> customerIds);

@Query("SELECT new Customers(id, abbreviation, shortName, longName) FROM Customers WHERE activeEntry = true ORDER BY abbreviation ASC")
public List<Customers> findDisplayInfo();

@Query("SELECT new Customers(id, abbreviation, shortName, longName) FROM Customers WHERE id IN :customerIds AND activeEntry = true")
public List<Customers> findDisplayInfoByIdIn(@Param("customerIds") List<Integer> customerIds);

@Query("SELECT new Customers(id, abbreviation, shortName, longName) FROM Customers WHERE abbreviation IN :abbreviations AND activeEntry = true")
public List<Customers> findDisplayInfoByAbbrIn(@Param("abbreviations") List<String> abbreviations);
}
<小时/>

客户

package com.csoln.lv.data.dom;

import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.Id;
import javax.persistence.Table;

import org.springframework.data.domain.Persistable;

import com.csoln.data.common.AbstractAbbreviation;
import com.csoln.data.listener.SimpleSequenceId;
import com.csoln.data.listener.SimpleSequenceIdListener;
import com.fasterxml.jackson.annotation.JsonIgnore;

/**
* @author eduardo.serrano
*
*/
@Entity
@Table(name = Customers.TABLE)
@EntityListeners(SimpleSequenceIdListener.class)
public class Customers extends AbstractAbbreviation implements Persistable<Integer>, SimpleSequenceId {

public static final String TABLE = "customers";
private static final long serialVersionUID = -8559335312619610990L;

@Id
private Integer id;

public Customers() {
super();
}

public Customers(Integer id, String abbreviation, String shortName, String longName) {
super();
this.id = id;
this.setAbbreviation(abbreviation);
this.setShortName(shortName);
this.setLongName(longName);
}
/**
* @return the id
*/
public Integer getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(Integer id) {
this.id = id;
}
/* (non-Javadoc)
* @see org.springframework.data.domain.Persistable#isNew()
*/
@Override
@JsonIgnore
public boolean isNew() {
return this.id == null;
}

/* (non-Javadoc)
* @see com.csoln.data.common.AbstractAuditable#toString()
*/
@Override
public String toString() {
return new StringBuilder("\n\r\t\t" + this.getClass().getName() + " - ID: " + this.id + ", " +super.toString()).toString();
}
}
<小时/>

BO

package com.csoln.lv.cld.bo;

import com.csoln.lv.data.dom.Customers;
import com.csoln.bo.common.AuditableBo;

public class CustomerBo extends AuditableBo<CustomerBo, Customers> {

private static final long serialVersionUID = 6234658974110288240L;
private Integer id;
private String abbreviation;
private String code;
private String label;
private Boolean activeEntry;

public CustomerBo() {
super();
}
public CustomerBo(Integer id, String abbreviation, String code, String label) {
super();
this.id = id;
this.abbreviation = abbreviation;
this.code = code;
this.label = label;
}
/**
* @return the id
*/
public Integer getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(Integer id) {
this.id = id;
}
/**
* @return the abbreviation
*/
public String getAbbreviation() {
return abbreviation;
}

public CustomerBo setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation;
return this;
}
/**
* @return the code
*/
public String getCode() {
return code;
}

public CustomerBo setCode(String code) {
this.code = code;
return this;
}
/**
* @return the label
*/
public String getLabel() {
return label;
}

public CustomerBo setLabel(String label) {
this.label = label;
return this;
}
/**
* @return the activeEntry
*/
public Boolean getActiveEntry() {
return activeEntry;
}
/**
* @param activeEntry the activeEntry to set
*/
public void setActiveEntry(Boolean activeEntry) {
this.activeEntry = activeEntry;
}

@SuppressWarnings("unchecked")
@Override
public <B extends CustomerBo> B toBo(Customers domain) {
if( domain != null ) {
super.toBo(domain);

this.id = domain.getId();
this.abbreviation = domain.getAbbreviation();
this.code = domain.getShortName();
this.label = domain.getLongName();
this.activeEntry = domain.getActiveEntry();

}
return (B) this;
}

public Customers toDomain() {
Customers domain = new Customers();
domain = super.toDomain(domain);
domain.setId(id);
domain.setAbbreviation(abbreviation);
domain.setLongName(this.label);
domain.setShortName(this.code);
domain.setActiveEntry(activeEntry);
return domain;
}

@Override
public boolean equals(Object obj) {
boolean equals = false;
if( obj instanceof CustomerBo ) {
CustomerBo i = (CustomerBo)obj;
equals = (id == i.getId());
}
return equals;
}

@Override
public int hashCode() {
return 4000;
}
}
<小时/>

错误

 SEVERE: Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'contextServiceImpl': Unsatisfied dependency expressed through field 'customersRepo'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.csoln.lv.data.cld.dao.CustomersRepo' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.csoln.lv.data.cld.dao.CustomersRepo' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
<小时/>

XML Spring 上下文文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">

<context:annotation-config></context:annotation-config>
<bean class="com.csoln.context.CsolnContext" />

<import resource="classpath:/props-context.xml"/>

<import resource="classpath:/config/data-context.xml" />
<import resource="classpath:/config/livedock-data-context.xml" />
<import resource="classpath:/config/security-context.xml" />
<import resource="classpath:/config/cache-context.xml" />

<context:component-scan base-package="
com.csoln.lookup,
com.csoln.lv.service">
</context:component-scan>

<bean class="com.csoln.service.ContextServiceImpl" />
<bean class="com.csoln.service.CodeServiceImpl" />
<bean class="com.csoln.service.ReferenceServiceImpl" />

<bean id="jsonProvider" class="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider" />
</beans>

最佳答案

这是因为您的 ComponentScan 没有看到您声明 @Service 的包。发布 Spring 上下文。

关于java - 我收到 BeanFactory 错误 : NoSuchBeanDefinitionException and I can't figure out how to solve it,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47961936/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com