多模块 spring 休眠,访问 dao 有困难,需要创建 spring bean xml?

Multimodule spring hibernate, difficulty with access to dao, need create spring bean xml?

我制作多模块应用程序(vaadin,spring,休眠) 我在访问 DAO(或模型,通常在持久性模块中具有持久性)时遇到很大问题

我需要在 core 中创建 spring xml bean 定义或在 中创建 spring bean ]web(在 applicationContext.xml 中)?

我收到错误:

services/TestService.java:[3,11] package dao does not exist
cannot find symbol  symbol:   class User
Generally core don't see persistence class

一般来说,我有 3 个模块:

核心pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 <parent>
    <artifactId>eControl</artifactId>
    <groupId>pl.cwik.dawid</groupId>
    <version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>core</artifactId>

<dependencies>
    <dependency>
        <groupId>pl.cwik.dawid</groupId>
        <artifactId>persistence</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.springframework/spring-beans -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>4.3.11.RELEASE</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-commons -->
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-commons</artifactId>
        <version>1.13.7.RELEASE</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa -->
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-jpa</artifactId>
        <version>1.11.7.RELEASE</version>
    </dependency>


</dependencies>

持久化pom

<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
    <artifactId>eControl</artifactId>
    <groupId>pl.cwik.dawid</groupId>
    <version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>persistence</artifactId>

<dependencies>
    <!-- https://mvnrepository.com/artifact/org.hibernate.javax.persistence/hibernate-jpa-2.1-api -->
    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.1-api</artifactId>
        <version>1.0.0.Final</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>5.2.11.Final</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>2.0.0.Final</version>
    </dependency>



    <!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>42.1.4</version>
    </dependency>


</dependencies>

问题是,maven项目persistence是版本1.0.0-SNAPSHOT。但是 core 依赖于 1.0-SNAPSHOT ,它要么是一个从未存在的版本,要么是一些旧版本丢失了一些文件。

问题通过评论@Vlasec 解决。

I noticed one problem in your XML. You are asking for persistence 1.0-SNAPSHOT, but your current version is 1.0.0-SNAPSHOT. That means you either get an older version, or you could also get no library at all if you never had 1.0-SNAPSHOT version. – Vlasec Nov 9 at 10:12

那是我的错,这真是一件愚蠢的事情!谢谢!