liuyangming / ByteTCC

ByteTCC is a distributed transaction manager based on the TCC(Try/Confirm/Cancel) mechanism. It’s compatible with the JTA specification. User guide: https://github.com/liuyangming/ByteTCC/wiki
https://www.bytesoft.org/
GNU Lesser General Public License v3.0
2.9k stars 913 forks source link

DataSource报错 #108

Open ElanZh opened 5 years ago

ElanZh commented 5 years ago

连接池使用Hikari,但是我有没有手动配置连接池,都会报以下错误:

2019-08-01 17:39:56.933  WARN 12942 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.bytesoft.bytetcc.supports.resource.LocalXADataSourcePostProcessor#0': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'transactionManager': Unsatisfied dependency expressed through field 'beanFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bytetccBeanFactory' defined in class path resource [bytetcc-supports-springcloud-primary.xml]: Cannot resolve reference to bean 'bytetccTransactionRepository' while setting bean property 'compensableRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bytetccTransactionRepository': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.apache.curator.framework.CuratorFramework' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup="", name="", description="", authenticationType=CONTAINER, type=java.lang.Object.class, mappedName="")}
2019-08-01 17:39:56.951  INFO 12942 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-08-01 17:39:57.196 ERROR 12942 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field beanFactory in org.bytesoft.bytetcc.TransactionManagerImpl required a bean of type 'org.apache.curator.framework.CuratorFramework' that could not be found.

The injection point has the following annotations:
    - @javax.inject.Inject()

Action:

Consider defining a bean of type 'org.apache.curator.framework.CuratorFramework' in your configuration.
liuyangming commented 5 years ago

使用MongoDB存储事务日志时,需要配置zookeeper,业务系统需要向spring定义一个CuratorFramework的bean实例。

ElanZh commented 5 years ago

使用MongoDB存储事务日志时,需要配置zookeeper,业务系统需要向spring定义一个CuratorFramework的bean实例。

我并没有配置事务日志,并且在启动类上已经加了 exclude = { MongoAutoConfiguration.class } 这个配置是默认的吗?还是说要在哪关掉?

ElanZh commented 5 years ago

使用MongoDB存储事务日志时,需要配置zookeeper,业务系统需要向spring定义一个CuratorFramework的bean实例。

maven配置里已经拆除这些依赖:


            <exclusions>
                <exclusion>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-zookeeper-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-zookeeper-discovery</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.netflix.eureka</groupId>
                    <artifactId>eureka-client</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-consul-discovery</artifactId>
                </exclusion>
            </exclusions>
liuyangming commented 5 years ago

样例的main类上一般都加了这么几行注释: // 按请求粒度负载均衡(使用MongoDB存储事务日志):需引入SpringCloudConfiguration; <br /> // 按事务粒度负载均衡(使用文件系统存储事务日志):需引入SpringCloudSecondaryConfiguration;

当通过@Import(SpringCloudConfiguration.class)引入bytetcc配置时,就说明是使用MongoDB存储事务日志了,这时就需要配置zookeeper定义CuratorFramework的bean实例; 如果想用文件记录事务日志,可以使用@Import(SpringCloudSecondaryConfiguration.class)这样的配置。

ElanZh commented 5 years ago

样例的main类上一般都加了这么几行注释: // 按请求粒度负载均衡(使用MongoDB存储事务日志):需引入SpringCloudConfiguration; <br /> // 按事务粒度负载均衡(使用文件系统存储事务日志):需引入SpringCloudSecondaryConfiguration;

当通过@Import(SpringCloudConfiguration.class)引入bytetcc配置时,就说明是使用MongoDB存储事务日志了,这时就需要配置zookeeper定义CuratorFramework的bean实例; 如果想用文件记录事务日志,可以使用@Import(SpringCloudSecondaryConfiguration.class)这样的配置。

明天我找找,用IDEA打开样例的时候乱码没注意