mirror of
https://github.com/OtusTeam/Spring.git
synced 2026-05-30 10:50:42 +00:00
mongo example and 2023-01 spring-15 java and boot version updated
This commit is contained in:
+7
-8
@@ -11,13 +11,13 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.2.1.RELEASE</version>
|
||||
<version>3.0.4</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -25,11 +25,10 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>org.springframework.data</groupId>-->
|
||||
<!--<artifactId>spring-data-keyvalue</artifactId>-->
|
||||
<!--<version>2.2.1.RELEASE</version>-->
|
||||
<!--</dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-keyvalue</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
+5
-7
@@ -1,21 +1,15 @@
|
||||
package ru.otus.spring;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.data.map.repository.config.EnableMapRepositories;
|
||||
import ru.otus.spring.domain.Person;
|
||||
import ru.otus.spring.repostory.PersonRepository;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Main.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("SpringJavaAutowiredFieldsWarningInspection")
|
||||
@Autowired
|
||||
private PersonRepository repository;
|
||||
@@ -26,4 +20,8 @@ public class Main {
|
||||
|
||||
repository.findAll();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Main.class);
|
||||
}
|
||||
}
|
||||
|
||||
-3
@@ -1,8 +1,5 @@
|
||||
package ru.otus.spring.domain;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.keyvalue.annotation.KeySpace;
|
||||
|
||||
public class Person {
|
||||
|
||||
private int id;
|
||||
|
||||
+3
-3
@@ -11,13 +11,13 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.2.1.RELEASE</version>
|
||||
<version>3.0.4</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
+1
-2
@@ -1,5 +1,6 @@
|
||||
package ru.otus.spring;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@@ -9,8 +10,6 @@ import ru.otus.spring.domain.Person;
|
||||
import ru.otus.spring.repostory.EmailRepository;
|
||||
import ru.otus.spring.repostory.PersonRepository;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableMapRepositories
|
||||
public class Main {
|
||||
|
||||
+2
-4
@@ -1,14 +1,12 @@
|
||||
package ru.otus.spring.repostory;
|
||||
|
||||
import org.springframework.data.keyvalue.repository.KeyValueRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import ru.otus.spring.domain.Email;
|
||||
import ru.otus.spring.domain.Person;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface EmailRepository {
|
||||
public interface EmailRepository {
|
||||
|
||||
List<Email> findAll();
|
||||
|
||||
Email save(Email email);
|
||||
}
|
||||
|
||||
+3
-1
@@ -5,6 +5,7 @@ import org.springframework.stereotype.Repository;
|
||||
import ru.otus.spring.domain.Email;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
@Repository
|
||||
public class EmailRepositoryImpl implements EmailRepository {
|
||||
@@ -17,7 +18,8 @@ public class EmailRepositoryImpl implements EmailRepository {
|
||||
|
||||
@Override
|
||||
public List<Email> findAll() {
|
||||
return (List<Email>) keyValueTemplate.findAll(Email.class);
|
||||
return StreamSupport.stream(keyValueTemplate.findAll(Email.class).spliterator(), false)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -1,12 +1,13 @@
|
||||
package ru.otus.spring.repostory;
|
||||
|
||||
import org.springframework.data.keyvalue.repository.KeyValueRepository;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import ru.otus.spring.domain.Person;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PersonRepository extends KeyValueRepository<Person, Integer> {
|
||||
|
||||
Person save(Person person);
|
||||
|
||||
List<Person> findAll();
|
||||
}
|
||||
|
||||
@@ -11,27 +11,34 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.3.4.RELEASE</version>
|
||||
<version>3.0.4</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<java.version>17</java.version>
|
||||
<maven.compiler.sourcre>17</maven.compiler.sourcre>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<mongock.version>4.3.8</mongock.version>
|
||||
<flapdoodle.version>4.6.1</flapdoodle.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>de.flapdoodle.embed</groupId>
|
||||
<artifactId>de.flapdoodle.embed.mongo</artifactId>
|
||||
<version>${flapdoodle.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>de.flapdoodle.embed</groupId>
|
||||
<artifactId>de.flapdoodle.embed.mongo.spring30x</artifactId>
|
||||
<version>${flapdoodle.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
-5
@@ -1,6 +1,5 @@
|
||||
package ru.otus.spring;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -10,10 +9,6 @@ import ru.otus.spring.repostory.PersonRepository;
|
||||
@SpringBootApplication
|
||||
public class Main {
|
||||
|
||||
@SuppressWarnings("SpringJavaAutowiredFieldsWarningInspection")
|
||||
@Autowired
|
||||
private PersonRepository repository;
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
ApplicationContext context = SpringApplication.run(Main.class);
|
||||
|
||||
|
||||
+7
@@ -1,4 +1,11 @@
|
||||
spring:
|
||||
data:
|
||||
mongodb:
|
||||
port: 0 # when flapdoodle using
|
||||
database: company
|
||||
|
||||
de:
|
||||
flapdoodle:
|
||||
mongodb:
|
||||
embedded:
|
||||
version: 4.0.2
|
||||
@@ -11,29 +11,35 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.3.4.RELEASE</version>
|
||||
<version>3.0.4</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<mongock.version>4.1.17</mongock.version>
|
||||
<java.version>17</java.version>
|
||||
<maven.compiler.sourcre>17</maven.compiler.sourcre>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<mongock.version>4.3.8</mongock.version>
|
||||
<flapdoodle.version>4.6.1</flapdoodle.version>
|
||||
</properties>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>de.flapdoodle.embed</groupId>
|
||||
<artifactId>de.flapdoodle.embed.mongo</artifactId>
|
||||
<version>${flapdoodle.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>de.flapdoodle.embed</groupId>
|
||||
<artifactId>de.flapdoodle.embed.mongo.spring30x</artifactId>
|
||||
<version>${flapdoodle.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
-5
@@ -1,7 +1,6 @@
|
||||
package ru.otus.spring;
|
||||
|
||||
import com.github.cloudyrock.spring.v5.EnableMongock;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -14,10 +13,6 @@ import ru.otus.spring.repostory.PersonRepository;
|
||||
@SpringBootApplication
|
||||
public class Main {
|
||||
|
||||
@SuppressWarnings("SpringJavaAutowiredFieldsWarningInspection")
|
||||
@Autowired
|
||||
private PersonRepository repository;
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
ApplicationContext context = SpringApplication.run(Main.class);
|
||||
|
||||
|
||||
+11
@@ -1,10 +1,21 @@
|
||||
spring:
|
||||
data:
|
||||
mongodb:
|
||||
port: 0 # when flapdoodle using
|
||||
database: company
|
||||
|
||||
de:
|
||||
flapdoodle:
|
||||
mongodb:
|
||||
embedded:
|
||||
version: 4.0.2
|
||||
|
||||
mongock:
|
||||
runner-type: "ApplicationRunner" # default
|
||||
#runner-type: "InitializingBean"
|
||||
change-logs-scan-package:
|
||||
- ru.otus.spring.mongock.changelog
|
||||
mongo-db:
|
||||
write-concern:
|
||||
journal: false
|
||||
read-concern: local
|
||||
|
||||
@@ -17,11 +17,12 @@
|
||||
<description>Demo project for MongoDB</description>
|
||||
|
||||
<properties>
|
||||
<java.version>11</java.version>
|
||||
<maven.compiler.sourcre>11</maven.compiler.sourcre>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<java.version>17</java.version>
|
||||
<maven.compiler.sourcre>17</maven.compiler.sourcre>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<mongock.version>4.3.8</mongock.version>
|
||||
<gson.version>2.9.0</gson.version>
|
||||
<flapdoodle.version>4.6.1</flapdoodle.version>
|
||||
<gson.version>2.10.1</gson.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -54,6 +55,7 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
@@ -63,14 +65,14 @@
|
||||
<dependency>
|
||||
<groupId>de.flapdoodle.embed</groupId>
|
||||
<artifactId>de.flapdoodle.embed.mongo</artifactId>
|
||||
<version>4.6.1</version>
|
||||
<version>${flapdoodle.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>de.flapdoodle.embed</groupId>
|
||||
<artifactId>de.flapdoodle.embed.mongo.spring30x</artifactId>
|
||||
<version>4.6.1</version>
|
||||
<version>${flapdoodle.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user