mirror of
https://github.com/tiennm99/try-spring-boot.git
synced 2026-08-04 23:13:50 +00:00
[Couchbase] (Add) try couchbase community 6.6.0
This commit is contained in:
@@ -3,11 +3,10 @@ package com.miti99.try_spring_boot;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@SpringBootApplication(scanBasePackages = "com.miti99.try_spring_boot")
|
||||
public class TrySpringBootApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(TrySpringBootApplication.class, args);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(TrySpringBootApplication.class, args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.miti99.try_spring_boot.controller;
|
||||
|
||||
import com.miti99.try_spring_boot.document.User;
|
||||
import com.miti99.try_spring_boot.repository.UserRepository;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||
public class UserController {
|
||||
final UserRepository userRepository;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
var user = new User("1", "name", "password", "value");
|
||||
userRepository.save(user);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.miti99.try_spring_boot.document;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.couchbase.core.index.QueryIndexed;
|
||||
import org.springframework.data.couchbase.core.mapping.Document;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Data
|
||||
@Document
|
||||
@NoArgsConstructor
|
||||
public class User {
|
||||
@Id String id;
|
||||
@QueryIndexed String name;
|
||||
|
||||
@QueryIndexed String password;
|
||||
|
||||
@QueryIndexed String value;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.miti99.try_spring_boot.repository;
|
||||
|
||||
import com.miti99.try_spring_boot.document.User;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
public interface UserRepository extends CrudRepository<User, String> {
|
||||
Optional<User> findById(String id);
|
||||
|
||||
List<User> findAllBy();
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
spring.application.name=try-spring-boot
|
||||
@@ -0,0 +1,15 @@
|
||||
spring:
|
||||
application:
|
||||
name: try-spring-boot
|
||||
couchbase:
|
||||
env:
|
||||
timeouts:
|
||||
view: 15000
|
||||
query: 15000
|
||||
connection-string: couchbase://127.0.0.1 # Your Couchbase connection string
|
||||
username: username # Your Couchbase username
|
||||
password: password # Your Couchbase password
|
||||
data:
|
||||
couchbase:
|
||||
bucket-name: try-spring-boot # Your Couchbase bucket name
|
||||
auto-index: true
|
||||
Reference in New Issue
Block a user