上下文初始化期间遇到异常 - 取消刷新尝试:org.springframework.beans.factory.Unsa



问题是,每次我运行项目时,都会出现来自org.springframework.beans.factory.UnsatisfiedDependencyException弹出窗口的错误。

我已经尝试了几个带有答案的相关问题,但问题尚未解决。

现场数据服务.java

@Component
public interface FieldDataService {
       public FieldData getFieldData() throws SQLException, Exception;
}

FieldDataServiceImpl.java

@Component
public class FieldDataServiceImpl implements FieldDataService {
    @Autowired
    FieldDataDao fieldDataDao;
    @Override
    public FieldData getFieldData() throws SQLException, Exception {
        return this.fieldDataDao.getFieldData();
    }
}

田地数据道.java

@Component
public interface FieldDataDao {
    public FieldData getFieldData() throws SQLException, Exception;
}

FieldDataDaoImpl.java

@Component
public class FieldDataDaoImpl implements FieldDataDao{
    @Autowired
    private SqlSession sqlSession;
    @Override
    public FieldData getFieldData() throws SQLException, Exception {
        FieldData result = new FieldData();
        try {
            result = this.sqlSession.selectOne("getFieldData");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }
}

现场数据.java

@Component
public class FieldData {
    private String transactionType;
    private String distribution;
    private Date startDate;
    private Date endDate;
    private String reportType;
    public String getTransactionType() {
        return transactionType;
    }
    public void setTransactionType(String transactionType) {
        this.transactionType = transactionType;
    }
    public String getDistribution() {
        return distribution;
    }
    public void setDistribution(String distribution) {
        this.distribution = distribution;
    }
    public Date getStartDate() {
        return startDate;
    }
    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }
    public Date getEndDate() {
        return endDate;
    }
    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }
    public String getReportType() {
        return reportType;
    }
    public void setReportType(String reportType) {
        this.reportType = reportType;
    }
    @Override
    public String toString() {
        return "FieldData [transactionType=" + transactionType + ", distribution=" + distribution + ", startDate="
                + startDate + ", endDate=" + endDate + ", reportType=" + reportType + "]";
    }
}

字段数据.xml

<mapper namespace="com.pnb.allianz.jdt.maper.FieldData">
     <resultMap id="FieldDataResultMap" type="FielData">
        <result column="LF2S_TRAN_TYPE"         property="transactionType"/>
        <result column="LF2S_DISTRIBUTION"      property="distribution"/>
        <result column="LF2S_REPORT_TYPE"   property="reportType"/>
    </resultMap>
    <select id="getFieldData" resultMap="FieldDataResultMap">
        SELECT * FROM LF2S_MR_PARAMETERS
        WHERE rownum =1
    </select>
</mapper>   

..错误是这样的

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'generateJdtController': Unsatisfied dependency expressed through field 'fieldDataService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataServiceImpl': Unsatisfied dependency expressed through field 'fieldDataDao'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataDaoImpl': Unsatisfied dependency expressed through field 'sqlSession'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionTemplate' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NullPointerException
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataService' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtserviceFieldDataService.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NullPointerException
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataService' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtserviceFieldDataService.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sqlSessionFactory': Requested bean is currently in creation: Is there an unresolvable circular reference?
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataDao' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtdaoFieldDataDao.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NullPointerException
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataDao' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtdaoFieldDataDao.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NullPointerException
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataDao' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtdaoFieldDataDao.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sqlSessionFactory': Requested bean is currently in creation: Is there an unresolvable circular reference?
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataService' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtserviceFieldDataService.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NullPointerException
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataService' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtserviceFieldDataService.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NullPointerException
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataService' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtserviceFieldDataService.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sqlSessionFactory': Requested bean is currently in creation: Is there an unresolvable circular reference?
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataDao' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtdaoFieldDataDao.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NullPointerException
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataDao' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtdaoFieldDataDao.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NullPointerException
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataDao' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtdaoFieldDataDao.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sqlSessionFactory': Requested bean is currently in creation: Is there an unresolvable circular reference?
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataService' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtserviceFieldDataService.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NullPointerException
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataService' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtserviceFieldDataService.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NullPointerException
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataService' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtserviceFieldDataService.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sqlSessionFactory': Requested bean is currently in creation: Is there an unresolvable circular reference?
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataDao' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtdaoFieldDataDao.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NullPointerException
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataDao' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtdaoFieldDataDao.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NullPointerException
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataDao' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtdaoFieldDataDao.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sqlSessionFactory': Requested bean is currently in creation: Is there an unresolvable circular reference?
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataService' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtserviceFieldDataService.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NullPointerException
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataService' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtserviceFieldDataService.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NullPointerException
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataService' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtserviceFieldDataService.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sqlSessionFactory': Requested bean is currently in creation: Is there an unresolvable circular reference?
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataDao' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtdaoFieldDataDao.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NullPointerException
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataDao' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtdaoFieldDataDao.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NullPointerException
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataDao' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtdaoFieldDataDao.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sqlSessionFactory': Requested bean is currently in creation: Is there an unresolvable circular reference?
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataService' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtserviceFieldDataService.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NullPointerException
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataDao' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtdaoFieldDataDao.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sqlSessionFactory': Requested bean is currently in creation: Is there an unresolvable circular reference?
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataDao' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtdaoFieldDataDao.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sqlSessionFactory': Requested bean is currently in creation: Is there an unresolvable circular reference?
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fieldDataService' defined in file [C:Usersmarkanthony.ragayDesktopjulia-document-trackingjulia-document-trackingtargetclassescompnballianzjdtserviceFieldDataService.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sqlSessionFactory': Requested bean is currently in creation: Is there an unresolvable circular reference?
2019-04-08 14:30:32.380  INFO 2284 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2019-04-08 14:30:32.410  INFO 2284 --- [  restartedMain] ConditionEvaluationReportLoggingListener :

提前感谢伙计们。希望你能帮助我。

您需要检查您的sqlSessionFactory。 此异常NullPointerException

您的错误消息

通过方法"sqlSessionTemplate"表示的未满足的依赖关系 参数 0;嵌套异常是 org.springframework.beans.factory.BeanCreationException: Error 创建在类路径中定义名称为"sqlSessionFactory"的 Bean 资源 [ org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: 通过工厂方法的 Bean 实例化失败;嵌套异常是 org.springframework.beans.BeanInstanceiationException: Failed to instanceiate [org.apache.ibatis.session.SqlSessionFactory]: Factory 方法 'sqlSessionFactory' 抛出异常;嵌套异常是 java.lang.NullPointerException

最新更新