programing

응용 프로그램의 클래스 경로를 수정하여 org.axonframework.eventsourcing.eventstore.jpa의 호환되는 단일 버전이 포함되도록 합니다.

closeapi 2023. 7. 20. 21:57
반응형

응용 프로그램의 클래스 경로를 수정하여 org.axonframework.eventsourcing.eventstore.jpa의 호환되는 단일 버전이 포함되도록 합니다.

작업 중입니다.Spring Boot + Axon예.유튜브의 https://www.youtube.com/watch?v=lBKZOTe9QM4&list=PL4O1nDpoa5KTq5QKX9ueK-0QCJ-6Wm_ma 링크를 팔로우하고 최신 종속 요소를 사용합니다.

사용한 경우axon-core그리고.axon-amqp로의 버전.3.0-RC1그러면 잘 작동합니다.하지만 3.4 버전을 사용하면 starup에서 아래와 같은 오류가 발생합니다.빨리 도와드릴까요?

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

Description:

An attempt was made to call the method org.axonframework.eventsourcing.eventstore.jpa.JpaEventStorageEngine.<init>(Lorg/axonframework/common/jpa/EntityManagerProvider;)V but it does not exist. Its class, org.axonframework.eventsourcing.eventstore.jpa.JpaEventStorageEngine, is available from the following locations:

    jar:file:/C:/Users/user/.m2/repository/org/axonframework/axon-core/3.4/axon-core-3.4.jar!/org/axonframework/eventsourcing/eventstore/jpa/JpaEventStorageEngine.class

It was loaded from the following location:

    file:/C:/Users/user/.m2/repository/org/axonframework/axon-core/3.4/axon-core-3.4.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.axonframework.eventsourcing.eventstore.jpa.JpaEventStorageEngine

pom.xml

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.6.RELEASE</version>
        <!-- <version>1.4.2.RELEASE</version> -->
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.axonframework</groupId>
            <artifactId>axon-spring-boot-starter</artifactId>
            <version>3.0-RC1</version>
        </dependency>

        <dependency>
            <groupId>org.axonframework</groupId>
            <artifactId>axon-amqp</artifactId>
            <!-- <version>3.0-RC1</version> -->
            <version>3.4</version>
        </dependency>
        <dependency>
            <groupId>org.axonframework</groupId>
            <artifactId>axon-core</artifactId>
            <!-- <version>3.0-RC1</version> -->
            <version>3.4</version>
        </dependency>
        <dependency>
            <groupId>org.hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-amqp</artifactId>
        </dependency> -->
    </dependencies>

데모 불만 Application.java

@SpringBootApplication
public class DemoComplaintsApplication {

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

    @RestController
    public static class ComplaintAPI {

        private final ComplaintQueryObjectRepository repostory;
        private final CommandGateway commandGateway;

        public ComplaintAPI(ComplaintQueryObjectRepository repostory, CommandGateway commandGateway) {
            this.repostory = repostory;
            this.commandGateway = commandGateway;
        }

        @PostMapping
        public CompletableFuture<String> fileCompplaint(@RequestBody Map<String, String> request) {
            String id = UUID.randomUUID().toString();
            return commandGateway
                    .send(new FileComplaintCommand(id, request.get("company"), request.get("description")));
        }

        @GetMapping
        public List<ComplaintQueryObject> findAll() {
            return repostory.findAll();
        }

        @GetMapping("/{id}")
        public ComplaintQueryObject find(@PathVariable String id) {
            //return repostory.findOne(id);
            return repostory.findById(id).get();
        }
    }

    @Aggregate
    public static class Complaint {
        @AggregateIdentifier
        private String complaintId;

        public Complaint() {
        }

        @CommandHandler
        public Complaint(FileComplaintCommand command) {
            apply(new ComplaintFileEvent(command.getId(), command.getCompany(), command.getDescription()));
        }

        @EventSourcingHandler
        public void on(ComplaintFileEvent event) {
            this.complaintId = event.getId();
        }
    }

    @Component
    public static class ComplaintQueryObjectUpdater {

        private final ComplaintQueryObjectRepository repository;

        public ComplaintQueryObjectUpdater(ComplaintQueryObjectRepository repository) {
            this.repository = repository;
        }

        @EventHandler
        public void on(ComplaintFileEvent event) {
            repository.save(new ComplaintQueryObject(event.getId(), event.getCompany(), event.getDescription()));
        }
    }

    public static class FileComplaintCommand {
        @TargetAggregateIdentifier
        private String id;
        private String company;
        private String description;

        public FileComplaintCommand(String id, String company, String description) {
            super();
            this.id = id;
            this.company = company;
            this.description = description;
        }

        public String getId() {
            return id;
        }

        public String getCompany() {
            return company;
        }

        public String getDescription() {
            return description;
        }
    }
}

문제는 다음과 같습니다.

    <dependency>
        <groupId>org.axonframework</groupId>
        <artifactId>axon-spring-boot-starter</artifactId>
        <version>3.0-RC1</version>
    </dependency>

다음과 같아야 합니다.

    <dependency>
        <groupId>org.axonframework</groupId>
        <artifactId>axon-spring-boot-starter</artifactId>
        <version>3.4</version>
    </dependency>

Axon 라이브러리를 v3.4로 업그레이드한 이후.

언급URL : https://stackoverflow.com/questions/53139869/correct-the-classpath-of-your-application-so-that-it-contains-a-single-compatib

반응형