简体   繁体   English

找不到软件包,Gradle构建

[英]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. 在我的ORMConfiguration文件中,我设置了实现JPA所需的一些基本属性。 Inside this ORMConfig.java file, I also have a main class. 在这个ORMConfig.java文件中,我还有一个主类。 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: 使用gradle构建项目,并通过以下方式设置依赖关系:

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 由于这是一个多模块项目,因此在我的课程中,前两个导入指向不同的模块,当我尝试从根或单个AMSRepository模块构建该完整项目时,出现错误

error: package io.good.asset.ams.model.domain does not exist import io.good.asset.ams.model.domain.Category; 错误:包io.good.asset.ams.model.domain不存在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; ^错误:包io.good.asset.ams.model.domain不存在import io.good.asset.ams.model.domain.Company;

My settings.gradle looks like this 我的settings.gradle看起来像这样

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. 我还使用了IntelliJ模块设置面板,并尝试向该模块麻烦的模块中手动添加小数,最奇怪的是,没有下划线是错误的,并且当我在ORMConfig.java中运行主类并从这些模块实例化对象时,一切正常。

Like a war file, a Spring Boot application is not intended to be used as a dependency. 像war文件一样,Spring Boot应用程序也不打算用作依赖项。 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 春季启动文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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