dracoblue.net

Review: Spring Boot Reference

TL;DR: Recommended?
Really good read! ⭐️⭐️⭐️⭐️
Read Online as:

This reference by @phillip_webb is a really good in depth introduction into all details of spring boot. Even though it's not about spring-data and all the other spring projects, it always provides as much information, which is necessary to understand what's spring boots role in the play.

The 24. Externalized Configuration section explains very well, how a spring boot application can be configured.

The [40. Testing] chapter is in my opinion not good enough, when it comes to testing with e.g. MockMvc and values of the application.yml (e.g. for @Value or SpEL).

In my use case I moved from the suggested version to this working version:

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = HttpResponseHeadersTestApplication.class)
@WebAppConfiguration
@IntegrationTest("server.port:0")
public class ExpressionControllerTest
{
    private MockMvc mockMvc;

    @Autowired
    private WebApplicationContext webApplicationContext;

    @Before
    public void setUp() {
        this.mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
    }

    @Test
    public void testValueExpression() throws Exception {
        MockHttpServletResponse response = this.mockMvc
                .perform(MockMvcRequestBuilders
                .get("/handleValueExpression"))
                .andReturn().getResponse();
        assertNotNull(response.getHeader("X-Key"));
        assertTrue(response.getHeader("X-Key").equals("X-Value-Method"));
        assertEquals(1, response.getHeaderNames().size());
    }
}

If somebody has a better (RestTemplate-based? - and more spring like) way how to handle that: you are welcome!

The 303 pages are a must read for everyone getting started with spring boot!

In java, read, spring, spring-boot by
@ 10 Nov 2015, Comments at Reddit & Hackernews

Give something back

Were my blog posts useful to you? If you want to give back, support one of these charities, too!

Report hate in social media Campact e.V. With our technology and your help, we protect the oceans from plastic waste. Gesellschaft fur Freiheitsrechte e. V. The civil eye in the mediterranean

Recent Dev-Articles

Read recently

Recent Files

About