Y
Y
Yasuro2019-08-27 00:34:41
Maven
Yasuro, 2019-08-27 00:34:41

How to avoid ClassNotFoundException in Spring + ArangoDb + Maven in a modularized project?

Created a module for working with arangoDb following the example . Here is the pom.xml:
5d644a31bb729482546772.png
Everything works well as it should.
I decided to split this example into modules, i.e. put everything that is not related to arango and spring data into a separate "core" module, and leave everything that is related to the database in the "kernel" working component.
pom.xml kernel:
5d645361f24bd021299735.png
Thus, only spring core was released into a separate "Core" module:

@SpringBootApplication
public class Core {
    public static void main(String[] args) {
        final Class<?>[] runner = new Class<?>[] { KernelRunner.class};
        System.exit(SpringApplication.exit(SpringApplication.run(runner,args)));
    }
}

@ComponentScan("com.name.proj.kernel") //пакет com.name.proj.kernel - из рабочего модуля (в котором вся логика с аранго)
public class KernelRunner implements CommandLineRunner {
    @Override
    public void run(String... args) throws Exception {
        System.out.println("it is runner");
    }
}

pom.xml Core components
5d644e0e3e627453874863.png
When I start Core I get an error:
Caused by: java.lang.ClassNotFoundException: com.arangodb.springframework.repository.ArangoRepository
ArangoRepository is the interface that I inherit to spring configure DAO:
public interface MyObjectRepository extends ArangoRepository<MyObject, String>

Why does spring not see ArangoRepository in such an implementation?
What Tried: ""

change pom.xml in core:
<dependency>
            <groupId>org.springframework.boot</groupId>
           Это: <artifactId>spring-boot-starter</artifactId> заменить на это: <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

Тогда получаю:
Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
StackOverflow говорит мл чтобы это пофиксить, надо добавить spring.main.web-application-type=none в application.properties. В таком случае, снова получаю ClassNotFoundException

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question