简体   繁体   中英

Package not found, Gradle build

I have the following problem. In my ORMConfiguration file I am setting up some of the basic properties that I need to implement JPA. Inside this ORMConfig.java file, I also have a main class. The class imports look like this

package io.good.asset.ams.dao.configuration;
import io.good.asset.ams.model.domain.Category;
import io.good.asset.ams.model.domain.Company;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import java.util.Map;

The project is built using gradle and depencies are set in the following manner:

project(':AMSRepository'){
    dependencies {
        compile project(':AMSModel')
        compile("org.springframework.boot:spring-boot-starter-jdbc:${springBootVersion}")
        compile("org.hibernate:hibernate-core:5.2.10.Final")
        compile("com.h2database:h2:${h2Ver}")

        testCompile("org.liquibase:liquibase-core:${liquibaseSpringVer}")
    }
}

Since this is a multi-modular project the first two imports in my class are pointing to the different module, and when I try to build that complete project from root, or individual AMSRepository module i get error that

error: package io.good.asset.ams.model.domain does not exist import io.good.asset.ams.model.domain.Category; ^ error: package io.good.asset.ams.model.domain does not exist import io.good.asset.ams.model.domain.Company;

My settings.gradle looks like this

rootProject.name = 'AMS'
include 'AMSRepository'
include 'AMSService'
include 'AMSWeb'
include 'AMSModel'

I have also used IntelliJ module settings panel and tried to add manually decencies to this module troublesome module, and the most weird this is that nothing is underlined as wrong and that when I run the main class in ORMConfig.java and instantiate objects from these modules, everything works fine.

Like a war file, a Spring Boot application is not intended to be used as a dependency. If your application contains classes that you want to share with other projects, the recommended approach is to move that code into a separate module. The separate module can then be depended upon by your application and other projects.

Spring Boot Doc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM