「SpringBootActualCombat」の読書ノート:
最近、SpringBootの実際の戦闘本を研究しています。SpringBootのバージョンが更新されたため、本のコードの一部が利用できなくなりました。この記事では、最初の3つの章で更新する必要のあるコードを示します。
第二章:
35ページのhtmlコード、id属性は入力に追加されず、id属性はlabelタグにバインドする必要があります
<form method="POST" >
<label for="title">Title:</label>
<input id="title" type="text" name="title" size="50"/><br/>
<label for="author">Author:</label>
<input id="author" type="text" name="author" size="50"/><br/>
<label for="isbn">ISBN:</label>
<input id="isbn" type="text" name="isbn" size="15"/><br/>
<label id="description" for="description">Description:</label><br/>
<textarea name="description" cols="80" rows="5">
</textarea><br/>
<input type="submit"/>
</form>
第3章:
45ページで、JavaコードのJpaRepositoryのfindOne()メソッドは廃止されました
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(new UserDetailsService() {
@Override
public UserDetails loadUserByUsername(String username)
throws UsernameNotFoundException {
return readerRepository.findById(username).get();
}
});
63ページで、画像は静止画/画像の下に配置する必要があります
<html>
<div class="errorPage">
<span class="oops">Oops!</span><br/>
<img th:src="@{/image/missingPage.png}"></img>
<p>There seems to be a problem with the page you requested
(<span th:text="${path}"></span>).</p>