|
1 | | -# Profile Store with Java SDK 3 and Spring Boot |
| 1 | +# Quickstart in Couchbase with C# and ASP .NET |
| 2 | +#### Build a REST API with Couchbase's C# SDK 3 and ASP .NET |
2 | 3 |
|
| 4 | +> This repo is designed to teach you how to connect to a Couchbase cluster to create, read, update, and delete documents and how to write simple parametrized N1QL queries. |
| 5 | +
|
| 6 | +[](https://gitpod.io/#https://github.com/couchbase-examples/java-springboot-quickstart) |
| 7 | + |
| 8 | +Full documentation can be found on the [Couchbase Developer Portal](https://developer.couchbase.com/tutorial-quickstart-springboot-java/). |
| 9 | +## Prerequisites |
| 10 | +To run this prebuilt project, you will need: |
| 11 | + |
| 12 | +- Couchbase 7 Installed (version 7.0.0-5247 or higher) |
| 13 | +- Java SDK v1.8 or higher installed |
| 14 | +- Code Editor installed (IntelliJ IDEA, Eclipse, or Visual Studio Code) |
| 15 | + |
| 16 | +## Install Dependencies |
| 17 | + |
| 18 | + |
| 19 | +```sh |
| 20 | +mvn package |
| 21 | +``` |
| 22 | +> Note: Maven packages auto restore when building the project in IntelliJ IDEA or Eclipse depending on IDE configuration. |
| 23 | +
|
| 24 | +### Database Server Configuration |
| 25 | + |
| 26 | +All configuration for communication with the database is stored in the `/src/main/java/resources/application.properties` file. This includes the connection string, username, and password. The default username is assumed to be `Administrator` and the default password is assumed to be `password`. If these are different in your environment you will need to change them before running the application. |
| 27 | + |
| 28 | +### Dependency Injection via DBSetupRunner class |
| 29 | + |
| 30 | +The quickstart code provides a CommandLineRunner called DBSetupRunner in the runners folder that wires up the Bucket and Cluster objects for dependency injection. This runner also creates the bucket, collection, scope, and indexes for the tutorial to run properly automatically when the application |
| 31 | + |
| 32 | +## Running The Application |
| 33 | + |
| 34 | +At this point the application is ready and you can run it via your IDE or from the terminal: |
| 35 | + |
| 36 | +```sh |
| 37 | +mvn spring-boot:run -e -X |
| 38 | +``` |
| 39 | + |
| 40 | +You can launch your browser and go to the [Swagger start page](https://localhost:5001/swagger/index.html). |
| 41 | + |
| 42 | +## Running The Tests |
| 43 | + |
| 44 | +To run the standard integration tests, use the following commands: |
| 45 | + |
| 46 | +To run the standard integration tests, use the following commands: |
| 47 | + |
| 48 | +```sh |
| 49 | +mvn test |
| 50 | +``` |
| 51 | + |
| 52 | +## Project Setup Notes |
| 53 | + |
| 54 | +This project was based on the standard link:https://spring.io/guides/gs/rest-service/[Spring Boot project]. The HealthCheckController is provided as a santity check and is used in unit tests. |
| 55 | + |
| 56 | +A fully list of packages are referenced in the pom.xml file |
| 57 | + |
| 58 | +## Conclusion |
| 59 | + |
| 60 | +Setting up a basic REST API in Spring Boot with Couchbase is fairly simple. This project when run with Couchbase Server 7 installed creates a bucket in Couchbase, an index for our parameterized link:https://docs.couchbase.com/java-sdk/current/howtos/n1ql-queries-with-sdk.html[N1QL query], and showcases basic CRUD operations needed in most applications. |
0 commit comments