morphia-spring-boot-parent

Spring boot starter using for morphia integration.

Лицензия

Лицензия

Категории

Категории

Spring Boot Контейнер Микросервисы
Группа

Группа

io.github.ganchix
Идентификатор

Идентификатор

morphia-spring-boot-parent
Последняя версия

Последняя версия

1.0.1
Дата

Дата

Тип

Тип

pom
Описание

Описание

morphia-spring-boot-parent
Spring boot starter using for morphia integration.
Ссылка на сайт

Ссылка на сайт

https://github.com/ganchix/morphia-spring-boot-starter
Система контроля версий

Система контроля версий

https://github.com/ganchix/morphia-spring-boot-starter/tree/master

Скачать morphia-spring-boot-parent

Имя Файла Размер
morphia-spring-boot-parent-1.0.1.pom 5 KB
Обзор

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/io.github.ganchix/morphia-spring-boot-parent/ -->
<dependency>
    <groupId>io.github.ganchix</groupId>
    <artifactId>morphia-spring-boot-parent</artifactId>
    <version>1.0.1</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/io.github.ganchix/morphia-spring-boot-parent/
implementation 'io.github.ganchix:morphia-spring-boot-parent:1.0.1'
// https://jarcasting.com/artifacts/io.github.ganchix/morphia-spring-boot-parent/
implementation ("io.github.ganchix:morphia-spring-boot-parent:1.0.1")
'io.github.ganchix:morphia-spring-boot-parent:pom:1.0.1'
<dependency org="io.github.ganchix" name="morphia-spring-boot-parent" rev="1.0.1">
  <artifact name="morphia-spring-boot-parent" type="pom" />
</dependency>
@Grapes(
@Grab(group='io.github.ganchix', module='morphia-spring-boot-parent', version='1.0.1')
)
libraryDependencies += "io.github.ganchix" % "morphia-spring-boot-parent" % "1.0.1"
[io.github.ganchix/morphia-spring-boot-parent "1.0.1"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.reflections : reflections jar 0.9.11

test (1)

Идентификатор библиотеки Тип Версия
org.springframework.boot : spring-boot-starter-test jar 1.5.3.RELEASE

Модули Проекта

  • morphia-spring-boot
  • morphia-spring-boot-starter

Spring boot starter Morphia Build Status codecov Maven Central GitHub stars

FOSSA Status

Spring boot starter for use Morphia in a Spring way easily.

Table of Contents

Overview

This implementation offers a Spring way to use Morphia framework, we use the configuration of Spring Data Mongo to instantiate Morphia and Datastore objects, both objects can be injected.

The starter scan Entity annotations to add in datastore and ensure indexes.

Getting started

Code example

First of all need to configure your properties like Spring Data Mongo, a example of application.properties :

spring.data.mongodb.uri=mongodb://user:password@ip:port/database
spring.data.mongodb.repositories.enabled=true

Create your domain classes, for example:

import lombok.Data;
import org.bson.types.ObjectId;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;

@Data
@Entity
public class Account {
    
    @Id
    private ObjectId id;
    private String user;
    private Double amount;
    private Long createdDate;
    
}

Create your repositories:

import org.mongodb.morphia.Datastore;
import org.mongodb.morphia.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
    
@Component
public class AccountRepositoryImpl implements AccountRepository {
    
    @Autowired
    private Datastore datastore;
    
    @Override
    public void delete(String user) {
        Query<Account> removeQuery = datastore.createQuery(Account.class)
                    .filter("user", user);
        datastore.delete(removeQuery);
    }
}

Integration using @SpringBootApplication or @EnableAutoConfiguration

Only add Maven dependency:

<dependency>
    <groupId>io.github.ganchix</groupId>
    <artifactId>morphia-spring-boot-starter</artifactId>
    <version>1.0.1</version>
</dependency>

Without @SpringBootApplication or @EnableAutoConfiguration

You need a @ComponentScan in the root package.

Add Maven dependency:

<dependency>
    <groupId>io.github.ganchix</groupId>
    <artifactId>morphia-spring-boot</artifactId>
    <version>1.0.1</version>
</dependency>

Import auto configuration MorphiaAutoConfiguration:

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
    
@Configuration
@Import(MorphiaAutoConfiguration.class)
public class MorphiaConfig {
    
}

License

Spring boot starter Morphia is licensed under the MIT License. See LICENSE for details.

Copyright (c) 2017 Rafael Ríos Moya

FOSSA Status

Версии библиотеки

Версия
1.0.1
1.0.0