{"id":65404,"date":"2020-08-31T15:57:08","date_gmt":"2020-08-31T15:57:08","guid":{"rendered":"https:\/\/www.baeldung.com\/?p=86423"},"modified":"2020-08-31T15:57:08","modified_gmt":"2020-08-31T15:57:08","slug":"guide-to-dynamicpropertysource-in-spring","status":"publish","type":"post","link":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/2020\/08\/31\/guide-to-dynamicpropertysource-in-spring\/","title":{"rendered":"Guide to @DynamicPropertySource in Spring"},"content":{"rendered":"<p class=\"syndicated-attribution\"><meta name= \\\"keywords \\\" content= \\\"\u96fb\u5b50\u8a08\u7b97\u6a5f, \u6559\u80b2, IT \u96fb\u8166\u73ed,\u96fb\u8166\u88dc\u7fd2\uff0c \u96fb\u8166\u73ed\uff0c \u5bb6\u6559\uff0c \u79c1\u4eba\u8001\u5e2b\uff0c \u8cc7\u8a0a\u6280\u8853\uff0c \u7a0b\u5e8f\u8a2d\u8a08\uff0c \u96fb\u5b50\u8a08\u7b97\u6a5f\uff0c \u904a\u6232\uff0c \u860b\u679c\uff0c \u96fb\u5f71\uff0c \u8a08\u7b97\u6a5f\uff0c\u7de8\u78bc\uff0c Java\uff0c C\/C++\uff0c JavaScript\uff0c PHP\uff0c HTML\uff0c CSS\uff0c MySQL\uff0c mobile\uff0c Android\uff0c \u52d5\u6f2b\uff0c Python\uff0c teacher\uff0c \u88dc\u7fd2\uff0c \u96fb\u8166\u88dc\u7fd2 \u8cc7\u8a0a, \u7535\u5b50\u8ba1\u7b97\u673a, IT ,Game, apple, movie, Computer,student,Java,\u6559\u80b2, ,\u5b66\u751f, \u5b66\u4e60, learn, \u6559\u5b66,  Android, apple,anime, animation, \u4fe1\u606f\u6280\u672f, \u7a0b\u5e8f\u8bbe\u8ba1, \u79fb\u52a8\u7535\u8bdd, \u8cc7\u8a0a\u79d1\u6280,Game, Jeu, Juego,Call Of Duty ,\u4f7f\u547d\u53ec\u559a , \u6e38\u620f, \u7535\u5b50\u6e38\u620f,, \u591a\u4eba\u7535\u5b50\u6e38\u620f, \u7f51\u7edc\u6e38\u620f\uff0conline\uff0conline game, \u624b\u673a\u6e38\u620f, mobile \\\"><\/p>\n<h2 data-id=\"overview\">1. Overview<\/h2>\n<div class=\"bd-anchor\" id=\"overview\"><\/div>\n<p>Today&#8217;s applications don&#8217;t live in isolation: we usually need to connect to various external components such as PostgreSQL, Apache Kafka, Cassandra, Redis, and other external APIs.<\/p>\n<p>In this tutorial, we&#8217;re going to see how Spring Framework 5.2.5 facilitates testing such applications with the introduction of <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/github.com\/spring-projects\/spring-framework\/issues\/24540\">dynamic properties<\/a>.<\/p>\n<p>First, we&#8217;ll start by defining the problem and seeing how we used to solve the problem in a less than ideal way. Then, we&#8217;ll introduce the <em><a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/docs.spring.io\/spring\/docs\/current\/javadoc-api\/org\/springframework\/test\/context\/DynamicPropertySource.html\">@DynamicPropertySource<\/a>\u00a0<\/em>annotation and see how it offers a better solution to the same problem. In the end, we&#8217;ll also take a look at another solution from test frameworks that can be superior compared to pure Spring solutions.<\/p>\n<h2 data-id=\"the-problem-dynamic-properties\">2. The Problem: Dynamic Properties<\/h2>\n<div class=\"bd-anchor\" id=\"the-problem-dynamic-properties\"><\/div>\n<p>Let&#8217;s suppose we&#8217;re developing a typical application that uses PostgreSQL as its database. We&#8217;ll begin with a simple JPA <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/jpa-entities\">entity<\/a>:<\/p>\n<pre><code class=\"language-java\">@Entity\r\n@Table(name = \"articles\")\r\npublic class Article {\r\n    @Id\r\n    @GeneratedValue(strategy = IDENTITY)\r\n    private Long id;\r\n    private String title;\r\n    private String content;\r\n    \/\/ getters and setters\r\n}<\/code><\/pre>\n<p>To make sure this entity works as expected, we should write a test for it to verify its database interactions. Since this test needs to talk to a real database, we should set up a PostgreSQL instance beforehand.<\/p>\n<p>There are <strong>different approaches to set up such infrastructural tools during test executions<\/strong>. As a matter of fact, there are three main categories of such solutions:<\/p>\n<ul>\n<li>Set up a separate database server somewhere just for the tests<\/li>\n<li>Use some lightweight, test-specific alternatives or fakes such as H2<\/li>\n<li>Let the test itself manage the lifecycle of the database<\/li>\n<\/ul>\n<p>As we shouldn&#8217;t differentiate between our test and production environments, there are better alternatives compared to using <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/monaa.dev\/posts\/mocks-considered-harmful\/\">test doubles such as H2<\/a>. <strong>The third option, in addition to working with a real database, offers better isolation for tests<\/strong>. Moreover, with technologies like Docker and <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/spring-boot-testcontainers-integration-test\">Testcontainers<\/a>, it&#8217;s easy to implement the third option.<\/p>\n<p>Here&#8217;s what our test workflow will look like if we use technologies like Testcontainers:<\/p>\n<ol>\n<li>Set up a component such as PostgreSQL before all tests. Usually, these components listen to random ports.<\/li>\n<li>Run the tests.<\/li>\n<li>Tear down the component.<\/li>\n<\/ol>\n<p><strong>If our PostgreSQL container is going to listen to a random port every time, then we should somehow set and change the <em>spring.datasource.url <\/em>configuration property dynamically<\/strong>. Basically, each test should have its own version of that configuration property.<\/p>\n<p>When the configurations are static, we can easily manage them using Spring Boot&#8217;s <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/properties-with-spring\">configuration management<\/a> facility. However, when we&#8217;re facing dynamic configurations, the same task can be challenging.<\/p>\n<p>Now that we know the problem, let&#8217;s see a traditional solution for it.<\/p>\n<h2 data-id=\"traditional-solution\">3. Traditional Solution<\/h2>\n<div class=\"bd-anchor\" id=\"traditional-solution\"><\/div>\n<p><strong>The first approach to implement dynamic properties is to use a custom <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/docs.spring.io\/spring\/docs\/current\/javadoc-api\/org\/springframework\/context\/ApplicationContextInitializer.html\"><em>ApplicationContextInitializer<\/em><\/a><\/strong>. Basically, we set up our infrastructure first and use the information from the first step to customize the\u00a0<a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/spring-application-context\"><em>ApplicationContext<\/em><\/a>:<\/p>\n<pre><code class=\"language-java\">@SpringBootTest\r\n@Testcontainers\r\n@ContextConfiguration(initializers = ArticleTraditionalLiveTest.EnvInitializer.class)\r\nclass ArticleTraditionalLiveTest {\r\n    @Container\r\n    static PostgreSQLContainer&lt;?&gt; postgres = new PostgreSQLContainer&lt;&gt;(\"postgres:11\")\r\n      .withDatabaseName(\"prop\")\r\n      .withUsername(\"postgres\")\r\n      .withPassword(\"pass\")\r\n      .withExposedPorts(5432);\r\n    static class EnvInitializer implements ApplicationContextInitializer&lt;ConfigurableApplicationContext&gt; {\r\n        @Override\r\n        public void initialize(ConfigurableApplicationContext applicationContext) {\r\n            TestPropertyValues.of(\r\n              String.format(\"spring.datasource.url=jdbc:postgresql:\/\/localhost:%d\/prop\", postgres.getFirstMappedPort()),\r\n              \"spring.datasource.username=postgres\",\r\n              \"spring.datasource.password=pass\"\r\n            ).applyTo(applicationContext);\r\n        }\r\n    }\r\n    \/\/ omitted \r\n}<\/code><\/pre>\n<p>Let&#8217;s walk through this somewhat complex setup. JUnit will create and start the container before anything else. After the container is ready, the Spring extension will call the initializer to apply the dynamic configuration to the Spring <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/docs.spring.io\/spring-framework\/docs\/current\/javadoc-api\/org\/springframework\/core\/env\/Environment.html\"><em>Environment<\/em><\/a>. <strong>Clearly, this approach is a bit verbose and complicated.<\/strong><\/p>\n<p>Only after these steps can we write our test:<\/p>\n<pre><code class=\"language-java\">@Autowired\r\nprivate ArticleRepository articleRepository;\r\n@Test\r\nvoid givenAnArticle_whenPersisted_thenShouldBeAbleToReadIt() {\r\n    Article article = new Article();\r\n    article.setTitle(\"A Guide to @DynamicPropertySource in Spring\");\r\n    article.setContent(\"Today's applications...\");\r\n    articleRepository.save(article);\r\n    Article persisted = articleRepository.findAll().get(0);\r\n    assertThat(persisted.getId()).isNotNull();\r\n    assertThat(persisted.getTitle()).isEqualTo(\"A Guide to @DynamicPropertySource in Spring\");\r\n    assertThat(persisted.getContent()).isEqualTo(\"Today's applications...\");\r\n}<\/code><\/pre>\n<h2 data-id=\"thedynamicpropertysource\">4. The\u00a0<em>@DynamicPropertySource<\/em><\/h2>\n<div class=\"bd-anchor\" id=\"thedynamicpropertysource\"><\/div>\n<p><strong>Spring Framework 5.2.5 introduced the\u00a0<em>@DynamicPropertySource\u00a0<\/em>annotation to facilitate adding properties with dynamic values<\/strong>. All we have to do is to create a static method annotated with <em>@DynamicPropertySource<\/em> and having just a single <em><a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/docs.spring.io\/spring\/docs\/current\/javadoc-api\/org\/springframework\/test\/context\/DynamicPropertyRegistry.html\">DynamicPropertyRegistry<\/a>\u00a0<\/em>instance as the input:<\/p>\n<pre><code class=\"language-java\">@SpringBootTest\r\n@Testcontainers\r\npublic class ArticleLiveTest {\r\n    @Container\r\n    static PostgreSQLContainer&lt;?&gt; postgres = new PostgreSQLContainer&lt;&gt;(\"postgres:11\")\r\n      .withDatabaseName(\"prop\")\r\n      .withUsername(\"postgres\")\r\n      .withPassword(\"pass\")\r\n      .withExposedPorts(5432);\r\n    @DynamicPropertySource\r\n    static void registerPgProperties(DynamicPropertyRegistry registry) {\r\n        registry.add(\"spring.datasource.url\", \r\n          () -&gt; String.format(\"jdbc:postgresql:\/\/localhost:%d\/prop\", postgres.getFirstMappedPort()));\r\n        registry.add(\"spring.datasource.username\", () -&gt; \"postgres\");\r\n        registry.add(\"spring.datasource.password\", () -&gt; \"pass\");\r\n    }\r\n    \r\n    \/\/ tests are same as before\r\n}<\/code><\/pre>\n<p>As shown above, we&#8217;re using the <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/docs.spring.io\/spring\/docs\/current\/javadoc-api\/org\/springframework\/test\/context\/DynamicPropertyRegistry.html#add-java.lang.String-java.util.function.Supplier-\"><em>add(String, Supplier&lt;Object&gt;) <\/em><\/a>method on\u00a0the given\u00a0<em>DynamicPropertyRegistry\u00a0<\/em>to add some properties to the Spring\u00a0<em>Environment<\/em>. This approach is much cleaner compared to the initializer one we saw earlier. <strong>Please note that methods annotated with\u00a0<em>@DynamicPropertySource\u00a0<\/em>must be declared as <em>static<\/em> and must accept only one argument of type\u00a0<em>DynamicPropertyRegistry<\/em>.\u00a0<\/strong><\/p>\n<p>Basically, the main motivation behind the\u00a0<em>@DynmicPropertySource\u00a0<\/em>annotation is to more easily facilitate something that was already possible. Although it was initially designed to work with Testcontainers, it&#8217;s possible to use it wherever we need to work with dynamic configurations.<\/p>\n<h2 data-id=\"an-alternative-test-fixtures\">5. An Alternative: Test Fixtures<\/h2>\n<div class=\"bd-anchor\" id=\"an-alternative-test-fixtures\"><\/div>\n<p>So far, in both approaches, <strong>the fixture setup and the test code are tightly intertwined<\/strong>. Sometimes, this tight coupling of two concerns complicates the test code, especially when we have multiple things to set up. Imagine what the infrastructure setup would look like if we were using PostgreSQL and Apache Kafka in a single test.<\/p>\n<p>In addition to that, <strong>the infrastructure setup and applying dynamic configurations will be duplicated in all tests that need them<\/strong>.<\/p>\n<p>To avoid these drawbacks, <strong>we can use test fixtures facilities that most testing frameworks provide<\/strong>. For instance, in JUnit 5, we can define an <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/junit-5-extensions\">extension<\/a> that starts a PostgreSQL instance before all tests, configures Spring Boot, and stops the PostgreSQL instance after running tests:<\/p>\n<pre><code class=\"language-java\">public class PostgreSQLExtension implements BeforeAllCallback, AfterAllCallback {\r\n    private PostgreSQLContainer&lt;?&gt; postgres;\r\n    @Override\r\n    public void beforeAll(ExtensionContext context) {\r\n        postgres = new PostgreSQLContainer&lt;&gt;(\"postgres:11\")\r\n          .withDatabaseName(\"prop\")\r\n          .withUsername(\"postgres\")\r\n          .withPassword(\"pass\")\r\n          .withExposedPorts(5432);\r\n        postgres.start();\r\n        String jdbcUrl = String.format(\"jdbc:postgresql:\/\/localhost:%d\/prop\", postgres.getFirstMappedPort());\r\n        System.setProperty(\"spring.datasource.url\", jdbcUrl);\r\n        System.setProperty(\"spring.datasource.username\", \"postgres\");\r\n        System.setProperty(\"spring.datasource.password\", \"pass\");\r\n    }\r\n    @Override\r\n    public void afterAll(ExtensionContext context) {\r\n        postgres.stop();\r\n    }\r\n}\r\n<\/code><\/pre>\n<p>Here, we&#8217;re implementing <em><a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/junit.org\/junit5\/docs\/5.1.1\/api\/org\/junit\/jupiter\/api\/extension\/AfterAllCallback.html\">AfterAllCallback<\/a>\u00a0<\/em>and\u00a0<em><a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/junit.org\/junit5\/docs\/5.1.1\/api\/org\/junit\/jupiter\/api\/extension\/BeforeAllCallback.html\">BeforeAllCallback<\/a>\u00a0<\/em>to create a JUnit 5 extension. This way, JUnit 5 will execute the <em>beforeAll()\u00a0<\/em>logic before running all the tests, and the logic in the <em>afterAll()\u00a0<\/em>method after running the tests. With this approach, our test code will be as clean as:<\/p>\n<pre><code class=\"language-java\">@SpringBootTest\r\n@ExtendWith(PostgreSQLExtension.class)\r\npublic class ArticleTestFixtureLiveTest {\r\n    \/\/ just the test code\r\n}<\/code><\/pre>\n<p>In addition to being more readable, we can easily reuse the same functionality just by adding the\u00a0<em>@ExtendWith(PostgreSQLExtension.class)<\/em> annotation. There&#8217;s no need to copy-paste the whole PostgreSQL setup everywhere we need it, as we did in the other two approaches.<\/p>\n<h2 data-id=\"conclusion\">6. Conclusion<\/h2>\n<div class=\"bd-anchor\" id=\"conclusion\"><\/div>\n<p>In this tutorial, we first saw how hard can it be to test a Spring component that depends on something like a database. Then, we introduced three solutions for this problem, each improving upon what the previous solution had to offer.<\/p>\n<p>As usual, all the examples are available <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/github.com\/eugenp\/tutorials\/tree\/master\/testing-modules\/spring-testing-2\">over on GitHub<\/a>.<\/p>\n<p>The post <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/spring-dynamicpropertysource\/\" >Guide to @DynamicPropertySource in Spring<\/a> first appeared on <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/\" >Baeldung<\/a>.<\/p>\n<p><Img align=\"left\" border=\"0\" height=\"1\" width=\"1\" alt=\"\" style=\"border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;\" hspace=\"0\" src=\"https:\/\/feeds.feedblitz.com\/~\/i\/634851708\/0\/baeldung\"><\/p>\n<div style=\"clear:both;padding-top:0.2em;\"><a title=\"Like on Facebook\" href=\"https:\/\/feeds.feedblitz.com\/_\/28\/634851708\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/fblike20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Share on Google+\" href=\"https:\/\/feeds.feedblitz.com\/_\/30\/634851708\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/googleplus20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Pin it!\" href=\"https:\/\/feeds.feedblitz.com\/_\/29\/634851708\/baeldung,\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/pinterest20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Tweet This\" href=\"https:\/\/feeds.feedblitz.com\/_\/24\/634851708\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/twitter20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Subscribe by email\" href=\"https:\/\/feeds.feedblitz.com\/_\/19\/634851708\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/email20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Subscribe by RSS\" href=\"https:\/\/feeds.feedblitz.com\/_\/20\/634851708\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/rss20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a rel=\"NOFOLLOW\" title=\"View Comments\" href=\"https:\/\/www.baeldung.com\/spring-dynamicpropertysource#respond\"><img decoding=\"async\" height=\"20\" style=\"border:0;margin:0;padding:0;\" src=\"https:\/\/assets.feedblitz.com\/i\/comments20.png\"><\/a>&#160;<a title=\"Follow Comments via RSS\" href=\"https:\/\/www.baeldung.com\/spring-dynamicpropertysource\/feed\/\"><img decoding=\"async\" height=\"20\" style=\"border:0;margin:0;padding:0;\" src=\"https:\/\/assets.feedblitz.com\/i\/commentsrss20.png\"><\/a>&#160;<\/div>\n\n<p class=\"syndicated-attribution\"><figure class= \\\"wp-block-image alignnone \\\"><img src= \\\"http:\/\/itteacheritfreelance.hk\/test\/wordpress\/wp-content\/uploads\/2016\/05\/logo2-2.png\\\" alt=\\\"IT\u96fb\u8166\u88dc\u7fd2 java\u88dc\u7fd2 \u70ba\u5927\u5bb6\u914d\u5c0d\u96fb\u8166\u88dc\u7fd2,IT freelance, \u79c1\u4eba\u8001\u5e2b, PHP\u88dc\u7fd2,CSS\u88dc\u7fd2,XML,Java\u88dc\u7fd2,MySQL\u88dc\u7fd2,graphic design\u88dc\u7fd2,\u4e2d\u5c0f\u5b78ICT\u88dc\u7fd2,\u4e00\u5c0d\u4e00\u79c1\u4eba\u88dc\u7fd2\u548cFreelance\u81ea\u7531\u5de5\u4f5c\u914d\u5c0d\u3002\\\"\/><figcaption>\u7acb\u523b\u8a3b\u518a\u53ca\u5831\u540d\u96fb\u8166\u88dc\u7fd2\u8ab2\u7a0b\u5427!<\/figcaption><\/figure>\r\n<\/br>Find A Teacher Form:\r\n<\/br>https:\/\/docs.google.com\/forms\/d\/1vREBnX5n262umf4wU5U2pyTwvk9O-JrAgblA-wH9GFQ\/viewform?edit_requested=true#responses\r\n<\/br><\/br>Email:\r\n<\/br>public1989two@gmail.com<br><br><br><br><br><br><br>\r\n<a href=www.itsec.hk style=color:#FFFFFF;>www.itsec.hk<\/a><br>\r\n<a href=\\\"www.itsec.vip\\\" style=color:#FFFFFF;>www.itsec.vip<\/a><br>\r\n<a href=\\\"www.itseceu.uk\\\" style=color:#FFFFFF;>www.itseceu.uk<\/a><br><\/p>","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>Learn how to leverage @DynamicPropertySource to manage testing with external applications.<\/p>\n<p>The post <a rel=\"NOFOLLOW noopener noreferrer\" href=\"https:\/\/feeds.feedblitz.com\/~\/634851708\/0\/baeldung~Guide-to-DynamicPropertySource-in-Spring\/\" target=\"_blank\">Guide to @DynamicPropertySource in Spring<\/a> first appeared on <a rel=\"NOFOLLOW noopener noreferrer\" href=\"https:\/\/www.baeldung.com\/\" target=\"_blank\">Baeldung<\/a>.<\/p>\n<div><a title=\"Like on Facebook\" href=\"https:\/\/feeds.feedblitz.com\/_\/28\/634851708\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/fblike20.png\"><\/a>&nbsp;<a title=\"Share on Google+\" href=\"https:\/\/feeds.feedblitz.com\/_\/30\/634851708\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/googleplus20.png\"><\/a>&nbsp;<a title=\"Pin it!\" href=\"https:\/\/feeds.feedblitz.com\/_\/29\/634851708\/baeldung,\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/pinterest20.png\"><\/a>&nbsp;<a title=\"Tweet This\" href=\"https:\/\/feeds.feedblitz.com\/_\/24\/634851708\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/twitter20.png\"><\/a>&nbsp;<a title=\"Subscribe by email\" href=\"https:\/\/feeds.feedblitz.com\/_\/19\/634851708\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/email20.png\"><\/a>&nbsp;<a title=\"Subscribe by RSS\" href=\"https:\/\/feeds.feedblitz.com\/_\/20\/634851708\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/rss20.png\"><\/a>&nbsp;<a rel=\"NOFOLLOW\" title=\"View Comments\" href=\"https:\/\/www.baeldung.com\/spring-dynamicpropertysource#respond\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/comments20.png\"><\/a>&nbsp;<a title=\"Follow Comments via RSS\" href=\"https:\/\/www.baeldung.com\/spring-dynamicpropertysource\/feed\/\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/commentsrss20.png\"><\/a>&nbsp;<\/div>\n<\/div>","protected":false},"author":760,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"Guide to @DynamicPropertySource in Spring - ITTeacherITFreelance.hk","description":"Learn how to leverage @DynamicPropertySource to manage testing with external applications. The post Guide to @DynamicPropertySource in Spring first appeared on"},"footnotes":""},"categories":[6],"tags":[],"_links":{"self":[{"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/65404"}],"collection":[{"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/760"}],"replies":[{"embeddable":true,"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=65404"}],"version-history":[{"count":10,"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/65404\/revisions"}],"predecessor-version":[{"id":70343,"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/65404\/revisions\/70343"}],"wp:attachment":[{"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=65404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=65404"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=65404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}