我正在将应用程序移植到Spring Boot和Spring Cassandra。我已经实例化了Cassandra Cluster。以前我的应用程序托管在Tomcat上(使用Spring Data Cassandra),我从来没有遇到同一个Jar的任何问题。今天当我将我的应用程序移植到Spring Boot时,当我尝试从我的JAR访问任何方法时,我收到以下错误 -
2017-01-20 14:38:16.017 INFO 6724 --- [主要] com.datastax.driver.core.Cluster:新的Cassandra主机 iacass302p.stress.ch3.s.com/10.235.91.41:9042已添加2017-01-20 14:38:16.017 INFO 6724 --- [主要] com.datastax.driver.core.Cluster:新的Cassandra主机 iacass301p.stress.ch3.s.com/10.235.91.40:9042已添加2017-01-20 14:38:16.017 INFO 6724 --- [主要] com.datastax.driver.core.Cluster:新的Cassandra主机 iacass303p.stress.ch3.s.com/10.235.91.42:9042已添加2017-01-20 14:38:16.017 INFO 6724 --- [主要] com.datastax.driver.core.Cluster:新的Cassandra主机 iacass402p.stress.ch4.s.com/10.236.67.50:9042已添加2017-01-20 14:38:16.017 INFO 6724 --- [主要] com.datastax.driver.core.Cluster:新的Cassandra主机 iacass401p.stress.ch4.s.com/10.236.66.83:9042已添加2017-01-20 14:38:16.017 INFO 6724 --- [主要] com.datastax.driver.core.Cluster:新的Cassandra主机 /10.236.67.51:9042已添加2017-01-20 14:38:17.646 INFO 6724 --- [
main] c.s.s.d.s.dao.impl.CacheBuilderDAOImpl:CacheBuilderDAOImpl: 内部方法init keyspace:capacity columnfamily:freight_lane 2017-01-20 14:39:03.755 WARN 6724 --- [主要] ationConfigEmbeddedWebApplicationContext:遇到异常 在上下文初始化期间 - 取消刷新尝试: org.springframework.beans.factory.UnsatisfiedDependencyException: 创建名为'deliveryCalendar3PLHandler'的bean时出错: 通过现场表达的不满意的依赖性 'deliveryCalendar3PLProcessor';嵌套异常是 org.springframework.beans.factory.UnsatisfiedDependencyException: 创建名为'deliveryCalendar3PLProcessor'的bean时出错: 通过现场表达的不满意的依赖性 'freightAreaStatusdDao';嵌套异常是 org.springframework.beans.factory.UnsatisfiedDependencyException: 创建名为'freightArea_Dao'的bean时出错:不满意 通过字段'cassandraOperations'表达的依赖;嵌套 例外是 org.springframework.beans.factory.NoSuchBeanDefinitionException:没有 合格的bean类型 'org.springframework.data.cassandra.core.CassandraOperations' 可用:预计至少有1个符合autowire资格的bean 候选人。依赖注释: {@ org.springframework.beans.factory.annotation.Autowired(所需=真), @ org.springframework.beans.factory.annotation.Qualifier(值= cassandraNewTemplate)} 2017-01-20 14:39:03.777 INFO 6724 --- [主要] o.apache.catalina.core.StandardService:停止服务Tomcat 2017-01-20 14:39:03.794 INFO 6724 --- [主要] utoConfigurationReportLoggingInitializer:启动ApplicationContext时出错。显示自动配置 报告在启用“debug”的情况下重新运行您的应用程序。 2017年1月20日 14:39:03.900 ERROR 6724 --- [主要] o.s.b.d.LoggingFailureAnalysisReporter:
***************************申请失败
说明
野外cassandraOperations in com.searshc.dce.persistence.DcePersistence.dao.impl.FreightAreaDaoImpl 需要一个类型的bean 'org.springframework.data.cassandra.core.CassandraOperations'那个 无法找到。
动作:
考虑定义类型的bean 您的“org.springframework.data.cassandra.core.CassandraOperations” 配置。
我的JAR中的代码摘录
@Component
public class FreightAreaDaoImpl
implements FreightAreaDao
{
private static Logger LOG = Logger.getLogger(FreightAreaDaoImpl.class);
@Autowired
@Qualifier("cassandraNewTemplate")
private CassandraOperations cassandraOperations;
private Session cassandraSession;
PreparedStatement getFreightLaneStmt = null;
public void initStatements()
{
if (this.cassandraOperations == null)
{
LOG.error("Cassandra not available");
}
else
{
LOG.error("FreightAreaDaoImpl:: Cassandra available: session initialized.");
this.cassandraSession = this.cassandraOperations.getSession();
this.getFreightLaneStmt = this.cassandraSession.prepare("select * from capacity.freight_area where geocode_no = ? ");
}
}
任何帮助将不胜感激!