Spring Boot,JPA(Eclipselink)JDNI数据源为JavaConfig

Spring Boot,JPA(Eclipselink)JDNI数据源为JavaConfig,java,spring,jpa,eclipselink,Java,Spring,Jpa,Eclipselink,目前,我的Spring Boot应用程序通过Web.xml使用JNDI查找数据源,效果良好: <resource-ref> <res-ref-name>jdbc/DefaultDB</res-ref-name> <res-type>javax.sql.DataSource</res-type> </resource-ref> 无法以错误开始: The dependencies of some of the

目前,我的Spring Boot应用程序通过Web.xml使用JNDI查找数据源,效果良好:

<resource-ref>
    <res-ref-name>jdbc/DefaultDB</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
</resource-ref> 
无法以错误开始:

The dependencies of some of the beans in the application context form a cycle
有人能告诉我如何将资源引用添加到我的配置文件中吗?谢谢你的帮助

下面是我的POM.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>

<groupId>de.info</groupId>
<artifactId>z_app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<name>Z_Application</name>
<description>z app</description>

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

<properties>
    <java.version>1.8</java.version>
    <eclipselink.version>2.6.4</eclipselink.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
        <exclusions>
            <exclusion>
                <artifactId>hibernate-entitymanager</artifactId>
                <groupId>org.hibernate</groupId>
            </exclusion>
             <exclusion>
                <artifactId>hibernate-core</artifactId>
                <groupId>org.hibernate</groupId>
            </exclusion> 
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>eclipselink</artifactId>
        <version>2.6.4</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-logging</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

4.0.0
de.info
z_应用程序
0.0.1-快照
战争
Z_应用程序
z应用程序
org.springframework.boot
spring启动程序父级
1.5.2.1发布
1.8
2.6.4
org.springframework.boot
SpringBootStarterWeb
org.springframework.boot
spring引导启动器数据jpa
休眠实体管理器
org.hibernate
冬眠核心
org.hibernate
org.eclipse.persistence
日食
2.6.4
org.springframework.boot
弹簧启动机tomcat
假如
org.springframework.boot
spring启动程序日志记录
假如
org.springframework.boot
spring引导配置处理器
真的
org.springframework.boot
springbootmaven插件

只要在application.properties中有
spring.datasource.jndi name=java:comp/env/jdbc/DefaultDB
即可配置jndi数据源。首先试试。如果要部署到容器,还需要
web.xml
(或
web fragment.xml
)中的条目。如果您使用的是嵌入式容器,那么不需要JNDI查找,因为这会使事情变得比需要的更复杂。就像Java类中的注释一样。但我不知道我的错。我还尝试了spring.datasource.jndi name=java:comp/env/jdbc/DefaultDB-end-with:name[jdbc/DefaultDB]在这个上下文中没有绑定。找不到[jdbc]。。。我想要部署我的应用程序的平台是SAP HCP(如果这有助于解决问题的话)。我在这篇文章中给出了所有建议,但它仍然不起作用
The dependencies of some of the beans in the application context form a cycle
<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>

<groupId>de.info</groupId>
<artifactId>z_app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<name>Z_Application</name>
<description>z app</description>

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

<properties>
    <java.version>1.8</java.version>
    <eclipselink.version>2.6.4</eclipselink.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
        <exclusions>
            <exclusion>
                <artifactId>hibernate-entitymanager</artifactId>
                <groupId>org.hibernate</groupId>
            </exclusion>
             <exclusion>
                <artifactId>hibernate-core</artifactId>
                <groupId>org.hibernate</groupId>
            </exclusion> 
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>eclipselink</artifactId>
        <version>2.6.4</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-logging</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>