国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

將 Spring Boot 應用程序與 Amazon DocumentDB 集成

這篇具有很好參考價值的文章主要介紹了將 Spring Boot 應用程序與 Amazon DocumentDB 集成。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

將 Spring Boot 應用程序與 Amazon DocumentDB 集成,spring boot,后端,java,spring

Amazon DocumentDB(與 MongoDB 兼容)是一種可擴展、高度持久和完全托管的數(shù)據(jù)庫服務(wù),用于操作任務(wù)關(guān)鍵型 MongoDB 工作負載。在 Amazon DocumentDB 上,您可以使用相同的 MongoDB 應用程序代碼、驅(qū)動程序和工具來運行、管理和擴展工作負載,無需關(guān)心管理底層基礎(chǔ)設(shè)施。?

Spring Boot?提供了簡單快速的方法,可基于 Spring 框架來構(gòu)建生產(chǎn)級的應用程序。為了做到這一點,Spring Boot 預先打包自動配置模塊,用于通常與?Spring Framework?一起使用的大多數(shù)庫。簡而言之,開源 Spring Boot 遵循有關(guān)配置的慣例,在 Spring 框架之上添加了自動配置功能。

在這篇文章中,您將探索使用?Spring Data MongoDB?API,將 Spring Boot 應用程序集成到 Amazon DocumentDB 的基礎(chǔ)知識。您還可以創(chuàng)建示例數(shù)據(jù)模型和存儲庫類用于執(zhí)行數(shù)據(jù)庫操作。

解決方案概覽

Spring Boot 和 Amazon DocumentDB 的配置相對簡單,只涉及幾個配置步驟。

Spring Boot 允許應用程序使用?MongoTemplate?類和?MongoRepository?接口,與 Amazon DocumentDB 交互。 MongoTemplate?遵循 Spring 中的標準模板模式,為底層持久性引擎提供了現(xiàn)成的基本 API。MongoTemplate?為聚合、流式處理、更新和自定義查詢等操作提供了直接可用的 API。MongoRepository?遵循以 Spring Data 為中心的方法,基于所有 Spring Data 項目中廣為人知的創(chuàng)建、讀取、更新和刪除(CRUD,Create, Read, Update, and Delete)訪問模式,提供了更靈活、更簡單的 API 操作。

對于這兩個選項,您首先要在?pom.xml?中為 Maven 項目定義依賴項。

這篇文章重點介紹如何使用?MongoRepository?與 Amazon DocumentDB 交互。

先決條件

您需要滿足以下先決條件:

  • Amazon DocumentDB 集群?– 這篇文章首先介紹現(xiàn)有的 Amazon DocumentDB 集群,您要將其與 Spring Boot 應用程序集成。如果您還沒有 Amazon DocumentDB 集群,請參閱?Get Started with Amazon DocumentDB(Amazon DocumentDB 入門)以創(chuàng)建新集群(https://docs.aws.amazon.com/documentdb/latest/developerguide/get-started-guide.html)。

  • 集成式開發(fā)環(huán)境(IDE)?– 例如,Eclipse?或?Amazon Cloud9。本文在演示中使用了 Amazon Cloud9,這是一款基于云的 IDE,讓您只需使用瀏覽器即可編寫、運行和調(diào)試代碼。其包括代碼編輯器、調(diào)試程序和終端。啟用增強了對 Java 開發(fā)的支持(https://docs.aws.amazon.com/cloud9/latest/user-guide/enhanced-java.html),改善您在使用 Java 時的開發(fā)體驗。

  • Java 17?– 有關(guān)在 Amazon Cloud9 中安裝或升級 Java 的信息,請參閱?Amazon Corretto 17 Installation Instructions(Amazon Corretto 17 安裝說明)(https://docs.aws.amazon.com/corretto/latest/corretto-17-ug/amazon-linux-install.html)

  • Maven?– 請參閱設(shè)置 Maven?以在 Amazon Cloud9 中安裝?Maven(https://docs.aws.amazon.com/cloud9/latest/user-guide/sample-java.html#sample-java-sdk-maven)

  • Spring Initializr

您的賬戶中可能會產(chǎn)生與 Amazon DocumentDB 和 Amazon Cloud9 資源相關(guān)的費用。您可以使用亞馬遜云科技定價計算器來估計此費用(https://calculator.aws/)。

使用 Spring Initializr?

創(chuàng)建 Spring Boot 應用程序

使用以下步驟,創(chuàng)建一個支持 Spring Data MongoDB 的新 Spring Boot 應用程序項目。作為替代方法,您可以使用?GitHub 存儲庫中的?spring-boot-docdb-sample?應用程序。(https://github.com/aws-samples/amazon-documentdb-samples/tree/master/blogs/docdb-springboot)

1. 瀏覽到?https://start.spring.io/。

2. 指定以下選項:

  1. 選擇?Maven project(Maven 項目),且?Language(語言)為?Java。

  2. 選擇 Spring Boot 的版本 3.0.0。

  3. 為應用程序指定組和構(gòu)件名稱。

  4. 指定 Java 版本 17。

  5. 選擇?ADD DEPENDENCIES(添加依賴項),然后搜索并選擇?Spring Data MongoDB。您可以使用 Spring Data MongoDB 依賴項,從此應用程序與 Amazon DocumentDB 集群進行交互。

3. 選擇?GENERATE(生成)以生成一個 Spring Boot 項目,其中包含引導所需的全部文件。

4. 將 ZIP 文件下載到本地計算機上的路徑并解壓縮文件。

將 Spring Boot 應用程序與 Amazon DocumentDB 集成,spring boot,后端,java,spring

如果您使用的是 Amazon Cloud9 IDE,請將 ZIP 文件上傳到 Amazon?Cloud9 環(huán)境并解壓縮文件。

驗證 Maven 依賴項

在應用程序的目錄中找到?pom.xml?文件,然后驗證是否已按如下方式添加 Spring Data MongoDB 依賴項:

?XML?

<dependency>
 ?<groupId>org.springframework.boot</groupId>
 ?<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>

左滑查看更多

定義數(shù)據(jù)模型

要在 Amazon DocumentDB 數(shù)據(jù)庫中存儲和檢索數(shù)據(jù),我們先創(chuàng)建一個 POJO 模型或?qū)嶓w類。該實體代表 Amazon DocumentDB 中的集合,并使用注釋來定義集合名稱、屬性、鍵和其他方面。

在此示例中,您創(chuàng)建一個產(chǎn)品集合和對應的模型對象,該對象將產(chǎn)品的詳細信息存儲在目錄數(shù)據(jù)庫中。您創(chuàng)建具有六個屬性的產(chǎn)品模型: id 、 name 、 sku 、 description 、 inventory?和?category 。

Amazon DocumentDB 在集合中存儲數(shù)據(jù)。默認情況下,Spring Data 將產(chǎn)品的類或模型映射到名為?product?的集合。如果要更改集合的名稱,您可以在類上使用 Spring Data MongoDB 的?@Document?注釋。在以下示例中,我們使用?@Document(collection = "products")?來將集合名稱指定為?products 。

您可以使用?@Id?注釋指定文檔的主鍵?_id 。如果您未指定任何內(nèi)容,Amazon DocumentDB 將在創(chuàng)建文檔時生成?_id?字段。其他屬性不添加注釋。這會假設(shè)它們映射到與屬性本身具有相同名稱的字段。在項目的目錄中,創(chuàng)建一個?Product.java?文件,其中具有以下內(nèi)容:

?Java?

@Id
 ? ?private String id; ? ?
 ? ?
 ? ?/** 
 ? ? * 設(shè)置對應于 products 集合中字段的數(shù)據(jù)成員
 ? ? */
 ? ? 
 ? ?private String name;
 ? ?private String sku;
 ? ?private String description;
 ? ?private int inventory;
 ? ?private String category;
 ? ?


 ? ?/**
 ? ? * @param id
 ? ? * @param name
 ? ? * @param sku
 ? ? * @param description
 ? ? * @param inventory
 ? ? * @param category
 ? ? */
 ? ?public Product(String name, String sku, String description, int inventory, String category) {
 ? ? ? ?
 ? ? ? ?this.name = name;
 ? ? ? ?this.sku = sku;
 ? ? ? ?this.description = description;
 ? ? ? ?this.inventory = inventory;
 ? ? ? ?this.category = category;
 ? ?}
}

左滑查看更多

為每個屬性添加 getter 和 setter 方法。您可以使用特定于 IDE 的快捷方式生成 getter 和 setter 方法。例如,右鍵單擊代碼編輯器窗格,選擇?Refactoring(重構(gòu)),然后選擇?Generate Getter and Setter in Cloud9(在 Cloud9 中生成 Getter 和 Setter)。

此外,建議覆蓋?toString?方法來輸出對象,例如,右鍵單擊代碼編輯器窗格,選擇?Refactoring(重構(gòu)),然后選擇?Generate toString() in Cloud9(在 Cloud9 中生成 toString())

將 Spring Boot 應用程序與 Amazon DocumentDB 集成,spring boot,后端,java,spring

在啟用 TLS 的情況下進行連接

要從基于 Java 的 Spring Boot 應用程序連接到啟用了 TLS 的 Amazon DocumentDB 集群,您的程序必須使用亞馬遜云科技提供的證書頒發(fā)機構(gòu)(CA,Certificate Authority)文件來驗證連接。要使用 Amazon RDS CA 證書,請執(zhí)行以下操作:

1. 在?tmp?文件夾下創(chuàng)建一個臨時?certs?文件夾。您可以根據(jù)組織的安全策略來創(chuàng)建用于存儲證書的文件夾。本文中,在?tmp?下創(chuàng)建?certs?文件夾:

?Bash?

mkdir /tmp/certs/

2. 運行以下命令,使用包含在文件中的 CA 證書創(chuàng)建信任存儲。請確保更新<truststorePassword>。以下 shell 腳本示例將證書捆綁包導入 Linux 操作系統(tǒng)上的信任存儲。有關(guān)其他選項,請參閱啟用了 TLS 的情況下的連接(https://docs.aws.amazon.com/documentdb/latest/developerguide/connect_programmatically.html#connect_programmatically-tls_enabled)。

?Bash?

mydir=/tmp/certs
truststore=${mydir}/rds-truststore.jks
storepassword=<truststorePassword>


curl -sS "https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem" > ${mydir}/rds-combined-ca-bundle.pem
awk 'split_after == 1 {n++;split_after=0} /-----END CERTIFICATE-----/ {split_after=1}{print > "rds-ca-" n ".pem"}' < ${mydir}/rds-combined-ca-bundle.pem


for CERT in rds-ca-*; do
 ?alias=$(openssl x509 -noout -text -in $CERT | perl -ne 'next unless /Subject:/; s/.*(CN=|CN = )//; print')
 ?echo "Importing $alias"
 ?keytool -import -file ${CERT} -alias "${alias}" -storepass ${storepassword} -keystore ${truststore} -noprompt
 ?rm $CERT
done


rm ${mydir}/rds-combined-ca-bundle.pem


echo "Trust store content is: "


keytool -list -v -keystore "$truststore" -storepass ${storepassword} | grep Alias | cut -d " " -f3- | while read alias 
do
 ? expiry=`keytool -list -v -keystore "$truststore" -storepass ${storepassword} -alias "${alias}" | grep Valid | perl -ne 'if(/until: (.*?)\n/) { print "$1\n"; }'`
 ? echo " Certificate ${alias} expires in '$expiry'" 
done

左滑查看更多

數(shù)據(jù)庫和連接配置

設(shè)置連接詳細信息和 SSL 信任存儲需要兩個配置文件。首先,在?application.properties?中定義您的 Amazon DocumentDB 連接參數(shù),例如數(shù)據(jù)庫、URI 或主機、端口、用戶名和密碼。然后在配置類中設(shè)置密鑰庫。

配置 Spring Boot 應用程序?qū)傩晕募?/strong>

要將 Spring Boot 應用程序連接到 Amazon DocumentDB,我們需要在?application.properties?文件中定義數(shù)據(jù)庫配置。您需要配置數(shù)據(jù)庫 URI、數(shù)據(jù)庫名稱或主機名、用戶名、密碼等屬性,以及其他與連接相關(guān)的屬性。要連接到 Amazon DocumentDB 集群,您需要在位于?src/main/resources?文件夾的?application.properties?文件中指定連接 URI 字符串。

要檢索您的 Amazon DocumentDB 集群端點并配置?application.properties ,請完成以下步驟:

1. 在 Amazon DocumentDB 控制臺的導航窗格中,選擇?Clusters(集群)。

2. 找到您的集群并選擇區(qū)域集群標識符。

3. 在?Connectivity & security(連接和安全性)選項卡上,復制用于通過 application.

將 Spring Boot 應用程序與 Amazon DocumentDB 集成,spring boot,后端,java,spring

連接到集群的命令。

4. 從復制的連接字符串中刪除?&ssl_ca_certs=rds-combined-ca-bundle.pem ,因為您已經(jīng)將亞馬遜云科技提供的 CA 文件導入了信任存儲。

5. 將連接 URI 添加到位于您的項目?src/main/resources?文件夾的?application.properties?文件中。連接 URI 的鍵為?spring.data.mongodb.uri 。確保復制的連接字符串格式如下:

spring.data.mongodb.uri=mongodb://<用戶名>:<密碼>@<集群端點>: 27017/?ssl=true&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false

左滑查看更多

或者,您可以單獨提供連接詳細信息,包括主機名、端口、用戶名和密碼以及對應的屬性鍵,例如?spring.data.mongodb.host?或?spring.data.mongodb.port 。有關(guān)可用的 Spring Boot 參數(shù)配置選項的完整列表,請參閱?Common Application Properties(常用應用程序?qū)傩裕┫碌?Data Properties(數(shù)據(jù)屬性)(https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html#appendix.application-properties.data)。

6. 您也可以選擇在?application.properties?文件中指定數(shù)據(jù)庫名稱:

spring.data.mongodb.database=catalog

創(chuàng)建配置類并設(shè)置密鑰庫

現(xiàn)在屬性配置已經(jīng)完成,您需要定義配置類來設(shè)置密鑰庫屬性,以便建立安全連接。

要在應用程序中使用密鑰庫,請在配置類中設(shè)置以下系統(tǒng)屬性:

javax.net.ssl.trustStore: <truststore>
javax.net.ssl.trustStorePassword: <truststorePassword>

左滑查看更多

請參閱以下示例配置類。使用?@Configuration?注釋將該類標記為配置類。具有?@Configuration?注釋的類由 Spring 容器用作 bean 定義的來源。

?Java?

@Bean
 ? ? ? ?public MongoClientSettings mongoClientSettings() { 
 ? ? ? ? ? ? setSslProperties();
 ? ? ? return MongoClientSettings.builder()
 ? ? ? ? ? ? ? ? ? ?.applyToSslSettings(builder -> builder.enabled(true))
 ? ? ? ? ? ? ? ? ? ?.build();
 ?}


 ? ? ? ?private static void setSslProperties() { 
 ? ? ? ? ? ?System.setProperty("javax.net.ssl.trustStore", KEY_STORE_TYPE);
 ? ? ? ? ? ?System.setProperty("javax.net.ssl.trustStorePassword", ? ? ? ? ?
 ? ? ? ? ? ? ? ? ? ?DEFAULT_KEY_STORE_PASSWORD);
 ? ? ? ?}
 ?@Bean
 ? ? ? ?public MongoPropertiesClientSettingsBuilderCustomizer mongoPropertiesCustomizer(final MongoProperties properties) {
 ? ? ?return new MongoPropertiesClientSettingsBuilderCustomizer(properties);
 ?}
}

左滑查看更多

以上是 Spring Boot 中 Amazon DocumentDB 配置的全部內(nèi)容現(xiàn)在,您可以通過擴展?MongoRepository?開始定義基于接口的存儲庫類。

配置存儲庫接口

現(xiàn)在,您可以使用?MongoRepository?訪問數(shù)據(jù)庫中的數(shù)據(jù)。 MongoRepository?提供常用功能,例如創(chuàng)建、讀取、更新和刪除(CRUD,Create, Read, Update, and Delete)操作。它充當模型與數(shù)據(jù)庫之間的鏈接。它獲取域類(Product)進行管理,并獲取域類的 ID 類型作為類型參數(shù)。您可以編寫幾種方法,由存儲庫為您生成查詢。

創(chuàng)建查詢?Product?文檔的存儲庫接口,如下所示:

?Java?

public interface ProductRepository extends MongoRepository<Product, String> {


}

左滑查看更多

?ProductRepository?擴展?MongoRepository?接口。此接口包含許多操作,包括標準的 CRUD 操作。您將在下一節(jié)中定義其他自定義操作。

定義服務(wù)類

服務(wù)類利用了 Spring Data 存儲庫接口。我們通過引用您在上一步中創(chuàng)建的存儲庫來定義它:

?Java?

@Service
public class ProductService {
 ? ?
 ? ?@Autowired
 ? ?private ProductRepository productRepo;
}

左滑查看更多

在下一節(jié)中,您將在此類上通過添加其他方法進行構(gòu)建,該節(jié)還介紹了 CRUD 示例。

使用 CrudRepository

使用擴展了?CrudRepository?的?MongoRepository?時,您的存儲庫可以從?CrudRepository?接口的實施類訪問基本功能,包括?save 、 count 、 findAll?和?delete?方法。您的?ProductRepository?接口擴展了?MongoRepository ,并可以訪問所有基本 CRUD 操作。

我們來逐個探索和測試這些操作。

保存或創(chuàng)建

首先,您使用?save?方法向集合中添加一些文檔。 save?方法獲取?Product?對象作為輸入,并將產(chǎn)品文檔保存到 Amazon DocumentDB 集合中。將以下代碼片段添加到您的服務(wù)類中:

?Java?

public void saveProducts() {
 
 ?productRepo.save(new Product("RayBan Sunglass Pro", "1590234","RayBan Sunglasses for professional sports people", 100, "fashion"));
 ?productRepo.save(new Product("GUCCI Handbag", "3451290", "Fashion Hand bags for all ages", 75, "fashion"));
 ?productRepo.save(new Product("Round hat", "8976045", "", 200, "fashion"));
 ?productRepo.save(new Product("Polo shirt", "6497023", "Cool shirts for hot summer", 25, "cloth"));
 ?productRepo.save(new Product("Swim shorts", "8245352", "Designer swim shorts for athletes", 200, "cloth"));
 ?productRepo.save(new Product("Running shoes", "3243662", "Shoes for work out and trekking", 20, "footware"));
 ?
 ?System.out.println(" Save complete ");
 ? ? ? ?
}

左滑查看更多

計數(shù)

在下一個示例中,如果存儲庫中沒有任何方法,則調(diào)用服務(wù)類中的?count() 方法,對集合中的文檔進行計數(shù)。

?Java?

public long getCount() {
 ? ?long count = productRepo.count();
 ? ?System.out.println(" Total number of products : "+count);
 ? ?return count;
}

左滑查看更多

讀取

在此示例中,您執(zhí)行三種不同的讀取操作。您可以按名稱或 SKU 提取產(chǎn)品,然后根據(jù)類別查找產(chǎn)品列表。

您在存儲庫( ProductRepository )中添加了三種簡單方法。第一種方法?findProductByName?根據(jù)?name?屬性查詢集合。查詢篩選條件使用注釋?@Query?定義,在本例中,注釋為?@Query("{name:'?0'}") 。第二種方法?findProductBySKU?根據(jù)?sku?屬性查詢集合,并在查詢響應中僅輸出?name?和?inventory?屬性。第三種方法?findAll?檢索特定類別的所有文檔。請參閱以下代碼:

?Java?

public interface ProductRepository extends MongoRepository<Product, String> {
 ? ?
 ? ?@Query("{name:'?0'}")
 ? ?Product findProductByName(String name);
 ? ?
 ? ?@Query(value="{sku:'?0'}", fields="{'name' : 1, 'inventory' : 1}")
 ? ?Product findProductBySKU (String sku); ? 


 ? ?@Query("{category:'?0'}")
 ? ?List<Product> findAllByCategory(String category);
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
}

左滑查看更多

您可以從存儲庫在服務(wù)類中調(diào)用這三種方法,按名稱、SKU 和類別查找文檔。

?Java?

public Product getProductByName(String name) {
 ?System.out.println(" Getting product by name : " + name);
 ?Product product = productRepo.findProductByName(name);
 ?System.out.println(product);
 ?return product; 
}


public Product getProductBySKU(String sku) {
 ?System.out.println(" Getting product by SKU : " + sku);
 ?Product product = productRepo.findProductBySKU(sku);
 ?System.out.println(product);
 ? return product; 
}


public List<Product> findAllProductsByCategory(String category) {
 ?List<Product> productList = productRepo.findAllByCategory(category);
 ?productList.forEach(product -> System.out.println(product));
 ?return productList;
}

左滑查看更多

更新

您可以通過傳遞更新后的實體對象,使用?save?方法來更新現(xiàn)有文檔。在此示例中,您按 SKU 查詢現(xiàn)有產(chǎn)品并將庫存增加 10。將以下方法添加到您的服務(wù)中:

?Java?

public void updateInventory(String sku) {
 ?Product product = ?getProductBySKU(sku);
 ?System.out.println(" Updating Inventory for product by sku: " + sku); ?
 ?product.setInventory(product.getInventory()+10);
 ?Product updatedProd = productRepo.save(product);
}

左滑查看更多

刪除

在本示例中,您將創(chuàng)建兩個刪除操作。首先,您按照 ID 刪除一個產(chǎn)品;在第二種方法中,您將刪除集合中的所有文檔(products)。將以下方法添加到您的服務(wù)類中:

?Java?

public void deleteProduct(String id) {
 ? productRepo.deleteById(id);
 ?System.out.println("Product with id " + id + " deleted");
}


public void deleteAll() {
 ?productRepo.deleteAll();
 ?System.out.println("All Products deleted.");
}

左滑查看更多

構(gòu)建 Spring Boot 應用程序

默認的 Spring Boot 應用程序已經(jīng)由 Spring Initializr 在根程序包(例如?com.example.documentdb )中創(chuàng)建。在 IDE 中打開默認應用程序:

?Java?

@SpringBootApplication
public class DocumentdbApplication {


 ?public static void main(String[] args) {
 ? ?SpringApplication.run(DocumentdbApplication.class, args);
 ?}
}

左滑查看更多

?CommandLineRunner?接口表明,當 bean 包含在?SpringApplication 中時應該運行,以便在控制臺上查看輸出。實施?CommandLineRunner?接口并為 run 方法提供植入方法。我們使用?@Autowired?注釋定義對您服務(wù)的引用。Spring 使用?@SpringBootApplication?注釋來初始化應用程序上下文:

?Java?

@Override
 ?public void run(String... args) throws Exception {
 ? ?
 ? ?System.out.printf("%n Insert few products : %n");
 ? ?prodService.saveProducts();
 ? ?
 ? ?System.out.printf("%n Count all products : %n");
 ? ?prodService.getCount();
 ? ?
 ? ?
 ? ?System.out.printf("%n Get product by name : %n");
 ? ?prodService.getProductByName("GUCCI Handbag");
 ? ?
 ? ?System.out.printf("%n Get product by sku : %n");
 ? ?prodService.getProductBySKU("8976045");
 ? ?
 ? ?System.out.printf("%n Get all products by category : %n");
 ? ?prodService.findAllProductsByCategory("fashion");
 ? ?
 ? ?System.out.printf("%n Update Inventory for Product by sku : ?%n");
 ? ?prodService.updateInventory("3451290");
 ? ?
 ? ?System.out.printf("%n Delete product id ?%n");
 ? ?prodService.deleteProduct("639a0046efe46b7343dd5004"); 
 ? ?
 ? ?System.out.printf("%n Deleting all products/documents ?%n");
 ? ?prodService.deleteAll(); 
 ?}
}

左滑查看更多

運行并測試您的應用程序

使用以下 Maven 命令運行 Spring Boot 應用程序:

?Bash?

mvn spring-boot:run

以下屏幕截圖是 Spring Boot 應用程序的示例輸出。

將 Spring Boot 應用程序與 Amazon DocumentDB 集成,spring boot,后端,java,spring

您做到了! 您已成功從 Spring Boot 應用程序連接到 Amazon DocumentDB。

總結(jié)

在這篇文章中,您了解了如何通過簡單的應用程序?qū)?Amazon DocumentDB 與 Spring Boot 應用程序集成,該應用程序使用 Spring Data MongoDB 將對象保存到數(shù)據(jù)庫以及從數(shù)據(jù)庫中提取對象,所有這些過程都無需編寫具體的存儲庫實施,而且配置簡單。

這篇文章中使用的示例在?GitHub?上作為示例項目提供(https://github.com/aws-samples/amazon-documentdb-samples/tree/master/blogs/docdb-springboot)。

Original URL:?

https://aws.amazon.com/cn/blogs/database/integrate-your-spring-boot-application-with-amazon-documentdb/

本篇作者

將 Spring Boot 應用程序與 Amazon DocumentDB 集成,spring boot,后端,java,spring

Gururaj S Bayari?

亞馬遜云科技的資深 DocumentDB 專家解決方案架構(gòu)師。他非常樂于幫助客戶采用 Amazon 的專用數(shù)據(jù)庫。他針對采用 NoSQL 和/或關(guān)系數(shù)據(jù)庫的互聯(lián)網(wǎng)規(guī)模的高性能工作負載,幫助客戶進行設(shè)計、評估和優(yōu)化。

將 Spring Boot 應用程序與 Amazon DocumentDB 集成,spring boot,后端,java,spring

將 Spring Boot 應用程序與 Amazon DocumentDB 集成,spring boot,后端,java,spring

聽說,點完下面4個按鈕

就不會碰到bug了!

將 Spring Boot 應用程序與 Amazon DocumentDB 集成,spring boot,后端,java,spring文章來源地址http://www.zghlxwxcb.cn/news/detail-693689.html

到了這里,關(guān)于將 Spring Boot 應用程序與 Amazon DocumentDB 集成的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔相關(guān)法律責任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • 【Spring Boot】數(shù)據(jù)庫持久層框架MyBatis — Spring Boot構(gòu)建MyBatis應用程序

    Spring Boot是用于快速構(gòu)建Spring應用程序的框架。MyBatis是一種Java持久化框架,可以幫助開發(fā)人員輕松地管理數(shù)據(jù)庫。將Spring Boot與MyBatis結(jié)合使用可以使開發(fā)人員更容易地創(chuàng)建和管理數(shù)據(jù)庫應用程序。 以下是使用Spring Boot構(gòu)建MyBatis應用程序的步驟: 添加MyBatis依賴項:在項目的

    2024年02月10日
    瀏覽(27)
  • 快速入門:使用 Spring Boot 構(gòu)建 Web 應用程序

    快速入門:使用 Spring Boot 構(gòu)建 Web 應用程序

    本文將討論以下主題: 安裝 Java JDK、Gradle 或 Maven 和 Eclipse 或 IntelliJ IDEA 創(chuàng)建一個新的 Spring Boot 項目 運行 Spring Boot 應用程序 編寫一個簡單的 Web 應用程序 打包應用程序以用于生產(chǎn)環(huán)境 通過這些主題,您將能夠開始使用 Spring Boot 并創(chuàng)建自己的 Web 應用程序。 Spring Boot是一個

    2024年02月07日
    瀏覽(70)
  • Spring Boot應用程序如何配置 HTTPS 訪問方式

    在 Spring Boot 應用程序中配置 HTTPS 訪問方式可以根據(jù)你是否擁有由受信任的證書頒發(fā)機構(gòu)(CA)簽發(fā)的證書來分為兩種情況:使用自簽名證書和使用 CA 簽發(fā)的證書。下面我將分別介紹這兩種情況的配置方法: 使用自簽名證書 如果你還沒有有效的 SSL/TLS 證書,可以選擇生成一個

    2024年01月20日
    瀏覽(18)
  • 輕松搞定Spring集成緩存,讓你的應用程序飛起來!

    輕松搞定Spring集成緩存,讓你的應用程序飛起來!

    主頁傳送門:?? 傳送 ??Spring 提供了對緩存的支持,允許你將數(shù)據(jù)存儲在緩存中以提高應用程序的性能。Spring 緩存抽象基于 Java Caching API,但提供了更簡單的編程模型和更高級的功能。 ??Spring 集成緩存提供了一種方便的方式來使用緩存,從而提高應用程序的性能。Spr

    2024年02月07日
    瀏覽(23)
  • 深入探討Spring Boot:實現(xiàn)一個完整的RESTful應用程序

    在這篇博客中,我們將深入探討如何使用Spring Boot構(gòu)建一個完整的RESTful應用程序,數(shù)據(jù)庫選擇MySQL。我們將通過實現(xiàn)一個簡單的用戶管理系統(tǒng)來演示Spring Boot的強大功能。 首先,訪問Spring Initializr,選擇以下依賴項: Web:用于創(chuàng)建Web應用程序 JPA:用于訪問數(shù)據(jù)庫 MySQL:用于連

    2024年02月03日
    瀏覽(18)
  • 使用Spring Boot和Docker快速部署Java應用程序

    隨著微服務(wù)的興起,容器化技術(shù)已成為現(xiàn)代應用程序開發(fā)和部署的關(guān)鍵部分。Docker作為一種流行的容器化解決方案,廣泛應用于企業(yè)和開發(fā)者社區(qū)。與此同時,Spring Boot作為一種優(yōu)秀的Java開發(fā)框架,大大簡化了基于Spring的應用程序開發(fā)。在本文中,我們將探討如何將Spring Bo

    2024年02月01日
    瀏覽(23)
  • “深入了解Spring Boot:構(gòu)建高效、可擴展的Java應用程序“

    標題:深入了解Spring Boot:構(gòu)建高效、可擴展的Java應用程序 摘要:Spring Boot是一款快速構(gòu)建Java應用程序的開發(fā)框架,它基于Spring框架,提供了一系列的自動化配置和約定,使得開發(fā)者能夠更快速、更高效地構(gòu)建出高質(zhì)量的應用程序。本文將深入探討Spring Boot的核心特性和使用

    2024年02月14日
    瀏覽(28)
  • “深入理解Spring Boot:構(gòu)建高效、可擴展的Java應用程序“

    標題:深入理解Spring Boot:構(gòu)建高效、可擴展的Java應用程序 摘要:Spring Boot是一個用于構(gòu)建Java應用程序的開源框架,它提供了一種簡單且高效的方式來創(chuàng)建獨立的、生產(chǎn)級別的應用程序。本文將深入探討Spring Boot的核心概念和特性,并通過示例代碼展示如何使用Spring Boot構(gòu)建

    2024年02月15日
    瀏覽(34)
  • Spring Boot實踐:構(gòu)建WebSocket實時通信應用程序并創(chuàng)建訂閱端點

    作為一款流行的Java開發(fā)框架,Spring Boot可以輕松地集成WebSocket。WebSocket能夠為Web應用程序提供實時通信功能,而Spring Boot的優(yōu)秀特性使得它可以很容易地實現(xiàn)WebSocket的集成。在本篇文章中,我們將演示如何使用Spring Boot框架來構(gòu)建一個簡單的WebSocket應用程序。 1. 創(chuàng)建Spring Boo

    2024年02月01日
    瀏覽(21)
  • 在 Spring Boot 應用程序中將 MapStruct 與 Lombok 結(jié)合使用的方法

    在本文中,您將找到有關(guān)如何高效使用 MapStruct、Lombok 和 Spring Boot 的代碼示例和說明。 ????????當您實現(xiàn)任何規(guī)模的服務(wù)時,您通常需要將數(shù)據(jù)從一種結(jié)構(gòu)移動到另一種結(jié)構(gòu)。通常,這是在不同邏輯層使用的相同數(shù)據(jù) - 在業(yè)務(wù)邏輯、數(shù)據(jù)庫級別或用于傳輸?shù)角岸藨贸绦?/p>

    2024年02月14日
    瀏覽(22)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包