Skip to content
This repository was archived by the owner on Sep 1, 2023. It is now read-only.

Commit 922c955

Browse files
GH-2 - Update to Spring Boot 2.2 and provide OGM 3.2.3 integration.
This brings the same OGM integration we have for the combination of Spring Boot 2.1 / OGM 3.1 / Driver 1.7 to the combination of Spring Boot 2.2 / OGM 3.2 / Driver 4.0.
1 parent 63617a5 commit 922c955

File tree

26 files changed

+791
-79
lines changed

26 files changed

+791
-79
lines changed

examples/dedicated-routing-driver/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<artifactId>spring-boot-starter-parent</artifactId>
66
<groupId>org.springframework.boot</groupId>
7-
<version>2.1.10.RELEASE</version>
7+
<version>2.2.1.RELEASE</version>
88
<relativePath></relativePath>
99
</parent>
1010

examples/ogm-integration/pom.xml

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<artifactId>spring-boot-starter-parent</artifactId>
6+
<groupId>org.springframework.boot</groupId>
7+
<version>2.2.1.RELEASE</version>
8+
<relativePath></relativePath>
9+
</parent>
10+
11+
<groupId>org.neo4j.doc.driver</groupId>
12+
<artifactId>ogm-integration-spring-boot-starter-example</artifactId>
13+
<version>999-SNAPSHOT</version>
14+
15+
<name>Example project that shows how the starter works with Neo4j-OGM.</name>
16+
<description>Demo project for Spring Boot</description>
17+
18+
<properties>
19+
<java.version>1.8</java.version>
20+
<neo4j-java-driver-spring-boot-starter.version>${revision}${sha1}${changelist}</neo4j-java-driver-spring-boot-starter.version>
21+
<neo4j-ogm.version>3.2.3</neo4j-ogm.version>
22+
<testcontainers.version>1.10.7</testcontainers.version>
23+
</properties>
24+
25+
<dependencies>
26+
<dependency>
27+
<groupId>com.github.ben-manes.caffeine</groupId>
28+
<artifactId>caffeine</artifactId>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.neo4j.driver</groupId>
32+
<artifactId>neo4j-java-driver-spring-boot-starter</artifactId>
33+
<version>${neo4j-java-driver-spring-boot-starter.version}</version>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.springframework.boot</groupId>
37+
<artifactId>spring-boot-starter-actuator</artifactId>
38+
</dependency>
39+
<dependency>
40+
<groupId>org.springframework.boot</groupId>
41+
<artifactId>spring-boot-starter-cache</artifactId>
42+
</dependency>
43+
<dependency>
44+
<groupId>org.springframework.boot</groupId>
45+
<artifactId>spring-boot-starter-data-neo4j</artifactId>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.springframework.boot</groupId>
49+
<artifactId>spring-boot-starter-test</artifactId>
50+
<scope>test</scope>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.springframework.boot</groupId>
54+
<artifactId>spring-boot-starter-web</artifactId>
55+
</dependency>
56+
<dependency>
57+
<groupId>org.testcontainers</groupId>
58+
<artifactId>junit-jupiter</artifactId>
59+
<version>${testcontainers.version}</version>
60+
<scope>test</scope>
61+
</dependency>
62+
<dependency>
63+
<groupId>org.testcontainers</groupId>
64+
<artifactId>neo4j</artifactId>
65+
<version>${testcontainers.version}</version>
66+
<scope>test</scope>
67+
</dependency>
68+
</dependencies>
69+
70+
<build>
71+
<plugins>
72+
<plugin>
73+
<groupId>com.github.ekryd.sortpom</groupId>
74+
<artifactId>sortpom-maven-plugin</artifactId>
75+
<version>2.8.0</version>
76+
<executions>
77+
<execution>
78+
<phase>verify</phase>
79+
<goals>
80+
<goal>sort</goal>
81+
</goals>
82+
</execution>
83+
</executions>
84+
<configuration>
85+
<encoding>${project.build.sourceEncoding}</encoding>
86+
<keepBlankLines>true</keepBlankLines>
87+
<nrOfIndentSpace>-1</nrOfIndentSpace>
88+
<sortProperties>true</sortProperties>
89+
<sortDependencies>groupId,artifactId</sortDependencies>
90+
<createBackupFile>false</createBackupFile>
91+
</configuration>
92+
</plugin>
93+
<plugin>
94+
<groupId>org.springframework.boot</groupId>
95+
<artifactId>spring-boot-maven-plugin</artifactId>
96+
</plugin>
97+
<plugin>
98+
<groupId>org.apache.maven.plugins</groupId>
99+
<artifactId>maven-install-plugin</artifactId>
100+
<configuration>
101+
<skip>true</skip>
102+
</configuration>
103+
</plugin>
104+
<plugin>
105+
<groupId>org.apache.maven.plugins</groupId>
106+
<artifactId>maven-deploy-plugin</artifactId>
107+
<configuration>
108+
<skip>true</skip>
109+
</configuration>
110+
</plugin>
111+
</plugins>
112+
</build>
113+
114+
<!-- Those profiles are not relevant to the examples and are only needed for SDN-RX release chain. -->
115+
<profiles>
116+
<profile>
117+
<id>revisionMissing</id>
118+
<activation>
119+
<property>
120+
<name>!revision</name>
121+
</property>
122+
</activation>
123+
<properties>
124+
<revision>4.0</revision>
125+
</properties>
126+
</profile>
127+
<profile>
128+
<id>sha1Missing</id>
129+
<activation>
130+
<property>
131+
<name>!sha</name>
132+
</property>
133+
</activation>
134+
<properties>
135+
<sha1></sha1>
136+
</properties>
137+
</profile>
138+
<profile>
139+
<id>changelistMissing</id>
140+
<activation>
141+
<property>
142+
<name>!changelist</name>
143+
</property>
144+
</activation>
145+
<properties>
146+
<changelist>-SNAPSHOT</changelist>
147+
</properties>
148+
</profile>
149+
</profiles>
150+
</project>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2019 "Neo4j,"
3+
* Neo4j Sweden AB [https://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* https://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.neo4j.doc.driver.springframework.boot.ogm_integration;
20+
21+
import org.springframework.boot.SpringApplication;
22+
import org.springframework.boot.autoconfigure.SpringBootApplication;
23+
import org.springframework.context.annotation.Bean;
24+
import org.springframework.data.neo4j.annotation.EnableBookmarkManagement;
25+
26+
@SpringBootApplication
27+
@EnableBookmarkManagement
28+
public class Application {
29+
30+
public static void main(String[] args) {
31+
SpringApplication.run(Application.class, args);
32+
}
33+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright (c) 2019 "Neo4j,"
3+
* Neo4j Sweden AB [https://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* https://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.neo4j.doc.driver.springframework.boot.ogm_integration.domain;
20+
21+
import org.neo4j.ogm.annotation.GeneratedValue;
22+
import org.neo4j.ogm.annotation.Id;
23+
import org.neo4j.ogm.annotation.NodeEntity;
24+
import org.springframework.data.annotation.PersistenceConstructor;
25+
26+
@NodeEntity("Movie")
27+
public class MovieEntity {
28+
29+
@Id @GeneratedValue
30+
private Long id;
31+
32+
private final String title;
33+
34+
@PersistenceConstructor
35+
MovieEntity(Long id, String title) {
36+
this.id = id;
37+
this.title = title;
38+
}
39+
40+
public MovieEntity(String title) {
41+
this(null, title);
42+
}
43+
44+
public Long getId() {
45+
return id;
46+
}
47+
48+
public String getTitle() {
49+
return title;
50+
}
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) 2019 "Neo4j,"
3+
* Neo4j Sweden AB [https://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* https://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.neo4j.doc.driver.springframework.boot.ogm_integration.domain;
20+
21+
import org.springframework.data.repository.CrudRepository;
22+
23+
public interface MovieRepository extends CrudRepository<MovieEntity, Long> {
24+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#
2+
# Copyright (c) 2019 "Neo4j,"
3+
# Neo4j Sweden AB [https://neo4j.com]
4+
#
5+
# This file is part of Neo4j.
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# https://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
org.neo4j.driver.uri=bolt://localhost:7687
20+
org.neo4j.driver.authentication.username=neo4j
21+
org.neo4j.driver.authentication.password=secret
22+
23+
org.neo4j.driver.pool.metrics-enabled=true
24+
25+
management.endpoints.web.exposure.include=info,health,metrics,conditions
26+
management.endpoint.health.show-details=always
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* Copyright (c) 2019 "Neo4j,"
3+
* Neo4j Sweden AB [https://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* https://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.neo4j.doc.driver.springframework.boot.ogm_integration;
20+
21+
import static org.assertj.core.api.Assertions.*;
22+
23+
import org.junit.jupiter.api.Test;
24+
import org.neo4j.driver.springframework.boot.autoconfigure.Neo4jDriverAutoConfiguration;
25+
import org.neo4j.driver.Driver;
26+
import org.neo4j.ogm.session.SessionFactory;
27+
import org.springframework.beans.factory.annotation.Autowired;
28+
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
29+
import org.springframework.boot.test.context.SpringBootTest;
30+
import org.springframework.boot.test.util.TestPropertyValues;
31+
import org.springframework.context.ApplicationContextInitializer;
32+
import org.springframework.context.ConfigurableApplicationContext;
33+
import org.springframework.data.neo4j.bookmark.BookmarkManager;
34+
import org.springframework.data.neo4j.web.support.OpenSessionInViewInterceptor;
35+
import org.springframework.test.context.ContextConfiguration;
36+
import org.springframework.transaction.PlatformTransactionManager;
37+
import org.testcontainers.containers.Neo4jContainer;
38+
import org.testcontainers.junit.jupiter.Container;
39+
import org.testcontainers.junit.jupiter.Testcontainers;
40+
41+
/**
42+
* This tests demonstrates that the automatic configuration for the driver integrates will with Spring Boot, meaning that
43+
* there's still a transaction manager, open session in view interceptor and bookmark support.
44+
*/
45+
@Testcontainers
46+
@SpringBootTest
47+
@ImportAutoConfiguration(Neo4jDriverAutoConfiguration.class)
48+
// This is necessary, as the test slice cannot know about it
49+
@ContextConfiguration(initializers = { ApplicationTest.Initializer.class })
50+
public class ApplicationTest {
51+
52+
@Container
53+
private static final Neo4jContainer neo4jContainer = new Neo4jContainer<>();
54+
55+
@Autowired
56+
private Driver driver;
57+
58+
@Autowired
59+
private SessionFactory sessionFactory;
60+
61+
@Autowired
62+
private PlatformTransactionManager transactionManager;
63+
64+
@Autowired
65+
private BookmarkManager bookmarkManager;
66+
67+
@Autowired
68+
private OpenSessionInViewInterceptor openSessionInViewInterceptor;
69+
70+
@Test
71+
void contextLoads() {
72+
assertThat(driver).isNotNull();
73+
assertThat(sessionFactory).isNotNull();
74+
assertThat(transactionManager).isNotNull();
75+
assertThat(bookmarkManager).isNotNull();
76+
assertThat(openSessionInViewInterceptor).isNotNull();
77+
}
78+
79+
static class Initializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
80+
public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
81+
82+
TestPropertyValues.of(
83+
"org.neo4j.driver.uri=" + neo4jContainer.getBoltUrl(),
84+
"org.neo4j.driver.authentication.username=neo4j",
85+
"org.neo4j.driver.authentication.password=" + neo4jContainer.getAdminPassword()
86+
).applyTo(configurableApplicationContext.getEnvironment());
87+
}
88+
}
89+
}

0 commit comments

Comments
 (0)