spring-boot-starter-data-cassandra-reactiv和多模块

时间:2018-07-24 11:49:52

标签: java spring cassandra reactive

我有2个小项目。 一个“公共”项目,位于其中的2个实体和2个存储库 fr.mycompany.commons.cassandra.entities:

例如,我的第一个实体:

package fr.mycompany.commons.cassandra.entities;

import lombok.*;
import org.springframework.data.cassandra.core.cql.PrimaryKeyType;
import org.springframework.data.cassandra.core.mapping.Column;
import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn;
import org.springframework.data.cassandra.core.mapping.Table;
@Data
@Builder
@Table("myfirstentity")
public class MyFirstEntity {
    ...
}

在fr.mycompany.commons.cassandra.repositories下:

package fr.mycompany.cassandra.repositories;
import fr.mycompany.commons.cassandra.entities.MyFirstEntity:
import org.springframework.data.cassandra.repository.ReactiveCassandraRepository;

public interface MyFirstRepository extends ReactiveCassandraRepository<MyFirstEntity, String> {
}

Y拥有第二个项目,例如“ loader”,而我的加载器对“ commmons”有maven依赖

我在课堂上使用的地方

@Autowired private MyFirstRepository myFirstRepository;

但是当我在Spring Boot应用程序中添加组件扫描时, 没有任何线索,应用程序无法完成启动... 例如:

@ComponentScan(useDefaultFilters = false, basePackages = {"fr.mycompany.commons.cassandra.repositories", "fr.mycompany.commons.cassandra..entities"})
@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

我已经读过某些博客,如果我们有两个分离的Maven模块,则必须指定组件扫描... 但是我尝试了几种配置,如useDefaultFilters = false(并且没有属性),仅使用basePackages =“ fr.mycompany.commons” 但实际上没有任何作用……简单的日志跟踪是:

2018-07-24 12:58:15,486 INFO [StartupInfoLogger.java:50] Starting Application on user1 with PID 10075 (/home/user1/Java/Workspaces/idea-workspace/loader/target/classes started by user1 in /home/user1/Java/Workspaces/idea-workspace/loader)
2018-07-24 12:58:15,494 DEBUG [StartupInfoLogger.java:53] Running with Spring Boot v2.0.1.RELEASE, Spring v5.0.5.RELEASE
2018-07-24 12:58:15,497 INFO [SpringApplication.java:659] No active profile set, falling back to default profiles: default
2018-07-24 12:58:18,713 INFO [StartupInfoLogger.java:59] Started Application in 3.603 seconds (JVM running for 4.386)

有人有主意吗?

感谢和问候,

Adrien

0 个答案:

没有答案