大家好,我收到了下一个错误,我是使用Hibernetes的新手
2022-09-08 15:16:47,070[Main]Info org.springframework.orm.hibernate4.HibernateTransactionManager-Using Hibernate SessionFactory for HibernateTransactionManager 2022-09-08 15:16:47,371[Main]WARN org.springframework.context.support.ClassPathXmlApplicationContext-上下文初始化时遇到异常-正在取消刷新尝试org.springframework.beans.factory.BeanCreationException:创建名为‘softwareVersionService’的Bean时出错:自动连接依赖项注入失败;嵌套异常为org.springframework.beans.factory.BeanCreationException:无法自动布线方法:公共空com.curcico.jproject.core.services.BaseAuditedEntityServiceImpl.setDao(com.curcico.jproject.core.daos.BaseAuditedEntityDao);嵌套异常为org.springframework.beans.factory.NoSuchBeanDefinitionException:找不到依赖项类型[ar.com.lakaut.sig.core.dao.SoftwareVersionDao]的限定Bean:应至少有1个Bean符合此依赖项的自动布线候选条件。依赖项注解:{}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1210) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83) at ar.com.lakaut.kiadesktop.frames.PrincipalContainer.main(PrincipalContainer.java:32) Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void com.curcico.jproject.core.services.BaseAuditedEntityServiceImpl.setDao(com.curcico.jproject.core.daos.BaseAuditedEntityDao); nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [ar.com.lakaut.sig.core.dao.SoftwareVersionDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:649) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ... 13 more Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [ar.com.lakaut.sig.core.dao.SoftwareVersionDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {} 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$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:606) ... 15 more Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'softwareVersionService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.fa ctory.BeanCreationException: Could not autowire method: public void com.curcico.jproject.core.services.BaseAuditedEntityServiceImpl.setDao(com.curcico.jproject.core.daos.BaseAuditedEntityDao); nested exception is org.springframework .beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [ar.com.lakaut.sig.core.dao.SoftwareVersionDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1210) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83) at ar.com.lakaut.kiadesktop.frames.PrincipalContainer.main(PrincipalContainer.java:32) ... 13 more Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [ar.com.lakaut.sig.core.dao.SoftwareVersionDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {} 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$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:606) ... 15 more
package ar.com.lakaut.sig.core.service;
import ar.com.lakaut.sig.core.domain.SoftwareVersion;
import com.curcico.jproject.core.services.BaseAuditedEntityService;
import com.curcico.jproject.core.exception.BaseException;
public interface SoftwareVersionService extends BaseAuditedEntityService<SoftwareVersion>{
public SoftwareVersion getSoftwareVersion(String name) throws BaseException;
public SoftwareVersion getSoftwareVersion(Integer id) throws BaseException;
public void addSoftwareVersion(SoftwareVersion softwareVersion) throws BaseException;
public void updateSoftwareVersion(SoftwareVersion oldSoftwareVersion, SoftwareVersion newSoftwareVersion) throws BaseException;
public void deleteSoftwareVersion(SoftwareVersion softwareVersion) throws BaseException;
}
package ar.com.lakaut.sig.core.dao;
import com.curcico.jproject.core.daos.BaseAuditedEntityDao;
import com.curcico.jproject.core.exception.BaseException;
import com.curcico.jproject.core.exception.InternalErrorException;
import ar.com.lakaut.sig.core.domain.SoftwareVersion;
public interface SoftwareVersionDao extends BaseAuditedEntityDao<SoftwareVersion>{
SoftwareVersion getSoftwareVersion(Integer id, boolean users) throws InternalErrorException;
SoftwareVersion getSoftwareVersion(Integer id) throws InternalErrorException;
SoftwareVersion getSoftwareVersion(String sft_product_name) throws InternalErrorException;
String getNextSoftwareVersionBarcodePrefix() throws BaseException;
}
package ar.com.lakaut.sig.core.dao;
import ar.com.lakaut.sig.core.domain.SoftwareVersion;
import com.curcico.jproject.core.daos.ConditionEntry;
import com.curcico.jproject.core.daos.ManagerAlias;
import com.curcico.jproject.core.daos.ManagerFetchs;
import com.curcico.jproject.core.exception.BaseException;
import com.curcico.jproject.core.exception.InternalErrorException;
import com.curcico.jproject.core.wrapper.GridWrapper;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.SessionFactory;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.curcico.jproject.core.daos.BaseAuditedEntityDaoImpl;
public class SoftwareVersionDaoImpl extends BaseAuditedEntityDaoImpl<SoftwareVersion> implements SoftwareVersionDao {
public SoftwareVersionDaoImpl() { }
@Override
public SoftwareVersion getSoftwareVersion(Integer id, boolean users) throws InternalErrorException {
return null;
}
@Override
public SoftwareVersion getSoftwareVersion(Integer id) throws InternalErrorException {
return null;
}
public SoftwareVersion getSoftwareVersion(String sft_product_name) throws InternalErrorException {
logger.debug("getLastKia-DesktopSoftwareVersion");
String sql = "select" + "* from sig_versions where sft_product_name like 'kiadoc-desktop' order by created_date DESC limit 1";
Query query = this.sessionFactory.getCurrentSession().createSQLQuery(sql);
List result = query.list();
SoftwareVersion softwareVersion = new SoftwareVersion();
softwareVersion.set_Version(result.get(0).toString());
return null;
}
@Override
public String getNextSoftwareVersionBarcodePrefix() throws BaseException {
return null;
}
@Override
public SoftwareVersion update(SoftwareVersion object, Integer user) throws BaseException {
return null;
}
@Override
public SoftwareVersion save(SoftwareVersion object, Integer user) throws BaseException {
return null;
}
@Override
public SoftwareVersion saveOrUpdate(SoftwareVersion object, Integer user) throws BaseException {
return null;
}
@Override
public SoftwareVersion delete(SoftwareVersion object, Integer user) throws BaseException {
return null;
}
@Override
public SoftwareVersion loadEntityById(Integer id) throws BaseException {
return null;
}
@Override
public SoftwareVersion loadEntityById(Integer id, Set<ManagerFetchs> fetchs) throws BaseException {
return null;
}
@Override
public SoftwareVersion loadEntityByFilters(List<ConditionEntry> filters) throws BaseException {
return null;
}
@Override
public SoftwareVersion loadEntityByFilters(List<ConditionEntry> filters, Set<ManagerFetchs> fetchs) throws BaseException {
return null;
}
@Override
public Long count() throws BaseException {
return null;
}
@Override
public Collection<? extends SoftwareVersion> findAll() throws BaseException {
return null;
}
@Override
public Collection<? extends SoftwareVersion> findAll(Integer numeroDePagina, Integer tamanioPagina) throws BaseException {
return null;
}
@Override
public Collection<? extends SoftwareVersion> findAll(String orderBy, String orderMode) throws BaseException {
return null;
}
@Override
public Collection<? extends SoftwareVersion> findAll(Integer numeroDePagina, Integer tamanioPagina, String orderBy, String orderMode) throws BaseException {
return null;
}
@Override
public List<Integer> getIds() throws BaseException {
return null;
}
@Override
public Long countByFilters(List<ConditionEntry> conditions) throws BaseException {
return null;
}
@Override
public Long countByFilters(Criteria criteria, List<ConditionEntry> filters) throws BaseException {
return null;
}
@Override
public Collection<? extends SoftwareVersion> findByFilters(List<ConditionEntry> conditions) throws BaseException {
return null;
}
@Override
public Collection<? extends SoftwareVersion> findByFilters(List<ConditionEntry> filters, Set<ManagerFetchs> fetchs) throws BaseException {
return null;
}
@Override
public Collection<? extends SoftwareVersion> findByFilters(List<ConditionEntry> conditions, Integer numeroDePagina, Integer tamanioPagina, String orderBy, String orderMode, Set<ManagerFetchs> fetchs) throws BaseException {
return null;
}
@Override
public Collection<? extends SoftwareVersion> findByFilters(Criteria criteria, List<ConditionEntry> filters, Integer page, Integer rows, String orderBy, String orderMode, Set<ManagerFetchs> fetchs) throws BaseException {
return null;
}
@Override
public GridWrapper<? extends SoftwareVersion> findByFiltersGridWrapper(List<ConditionEntry> filters, Integer page, Integer rows, String orderBy, String orderMode, Set<ManagerFetchs> fetchs) throws BaseException {
return null;
}
@Override
public Set<ManagerAlias> getAlias() {
return null;
}
@Override
public Set<ManagerFetchs> getFetchs() {
return null;
}
@Override
public SessionFactory getSessionFactory() {
return null;
}
@Override
public List<List<String>> getContentReportGeneric(String sql, Map<String, Object> param, List<String> fieldSelect) {
return null;
}
@Override
public Criteria getCriteria() throws BaseException {
return null;
}
@Override
public Criteria getCriteria(String alias) throws BaseException {
return null;
}
}
package ar.com.lakaut.sig.core.service;
import ar.com.lakaut.sig.core.domain.SoftwareVersion;
import com.curcico.jproject.core.exception.BaseException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.curcico.jproject.core.services.BaseAuditedEntityServiceImpl;
import ar.com.lakaut.sig.core.dao.SoftwareVersionDao;
import org.apache.log4j.Logger;
@Service("softwareVersionService")
public class SoftwareVersionServiceImpl extends BaseAuditedEntityServiceImpl<SoftwareVersion, SoftwareVersionDao> implements SoftwareVersionService {
Logger logger = Logger.getLogger(SoftwareVersionServiceImpl.class);
@Autowired
private SoftwareVersionDao softwareVersionDao;
@Override
public SoftwareVersion getSoftwareVersion(Integer id) throws BaseException {
logger.info("softwareVersionId: " + id);
return softwareVersionDao.getSoftwareVersion(id);
}
@Override
public SoftwareVersion getSoftwareVersion(String sft_product_name) throws BaseException {
logger.info("softwareVersionId: " + sft_product_name);
return softwareVersionDao.getSoftwareVersion(sft_product_name);
}
@Override
public void addSoftwareVersion(SoftwareVersion softwareVersion) throws BaseException {
}
@Override
public void updateSoftwareVersion(SoftwareVersion oldSoftwareVersion, SoftwareVersion newSoftwareVersion) throws BaseException {
}
@Override
public void deleteSoftwareVersion(SoftwareVersion softwareVersion) throws BaseException {
}
@Override
public SoftwareVersion update(SoftwareVersion object, Integer user) throws BaseException {
return null;
}
@Override
public SoftwareVersion save(SoftwareVersion object, Integer user) throws BaseException {
return null;
}
@Override
public SoftwareVersion saveOrUpdate(SoftwareVersion object, Integer user) throws BaseException {
return null;
}
@Override
public SoftwareVersion delete(SoftwareVersion object, Integer user) throws BaseException {
return null;
}
}
package ar.com.lakaut.sig.core.domain;
import com.curcico.jproject.core.entities.BaseAuditedEntity;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import javax.persistence.*;
import java.io.Serializable;
@Entity
@Table(name = "sig_versions")
@SQLDelete(sql="UPDATE sig_versions SET deleted = '1' WHERE version_id = ? and version = ?")
@Where(clause="deleted is null")
public class SoftwareVersion extends BaseAuditedEntity implements Serializable {
public SoftwareVersion() {}
private String product_name;
private String sft_version;
private String obs;
public SoftwareVersion(String product_name, String version, String obs, Integer created_user, Integer updated_user) {
super();
this.id = id;
this.product_name = product_name;
this.sft_version = version;
this.obs = obs;
}
public SoftwareVersion(Integer id){
super();
setId(id);
}
public void setProduct_name(String product_name) {
this.product_name = product_name;
}
@Id
@SequenceGenerator(name = "id_generator", sequenceName = "sig_versions_config_seq", allocationSize = 1)
@GeneratedValue(generator = "id_generator", strategy =GenerationType.SEQUENCE)
@Column(name = "sft_id", unique = true, nullable = false)
public Integer getId() { return this.id; }
@Column(name = "sft_product_name", nullable = false)
public String getProductName() { return product_name; }
public void setProductName(String product_name) { this.product_name = product_name; }
@Column(name = "sft_version", nullable = false)
public String get_Version() { return sft_version; }
public void set_Version(String version) { this.sft_version = version; }
@Column(name = "sft_obs", nullable = false)
public String getObs() { return obs; }
public void setObs(String obs) { this.obs = obs; }
}
1条答案
按热度按时间qfe3c7zg1#
谢谢你们的帮助。我已经用这种方法解决了。
我已经添加了@Repository注解和Super();构造函数