提交用例
This commit is contained in:
@ -0,0 +1,14 @@
|
||||
package com.heibaiying.springboot;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SpringBootMongodbApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringBootMongodbApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
package com.heibaiying.springboot.bean;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author : heibaiying
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Programmer {
|
||||
|
||||
@Id
|
||||
private String name;
|
||||
|
||||
private int age;
|
||||
|
||||
private float salary;
|
||||
|
||||
private Date birthday;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.heibaiying.springboot.repository;
|
||||
|
||||
import com.heibaiying.springboot.bean.Programmer;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
/**
|
||||
* @author : heibaiying
|
||||
* @description : jpa 方式查询 对于mongo而言 更推荐这种查询方式 比起原生的语法更加简洁
|
||||
*/
|
||||
public interface ProgrammerRepository extends MongoRepository<Programmer, String> {
|
||||
|
||||
void deleteAllByName(String name);
|
||||
|
||||
Programmer findAllByName(String names);
|
||||
|
||||
Programmer findByNameAndAge(String name, int age);
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
spring:
|
||||
data:
|
||||
mongodb:
|
||||
database: spring
|
||||
uri: mongodb://192.168.0.108:27017
|
Reference in New Issue
Block a user