A minimal Java app that demonstrates CRUD for a single entity Note using Spring Boot MVC, Thymeleaf, Spring Data JPA, H2, and Flyway.
✅What’s New (Security)
Added dependency: spring-boot-starter-security.
On startup, Spring Boot shows a generated password in logs:
Using generated security password: 6a4b3e7f-...
Default username: user. Enter these credentials at the login page to access the app.
Optional (dev only): to avoid generated passwords each run, you may set fixed creds in application.properties:
spring.security.user.name=admin spring.security.user.password=admin
(Not required by the assignment.)
Note
id
(Long, auto-generated)title
(String, required)content
(String, up to 2000 chars)
@Entity
-annotatedNote
mapped to tablenote
NoteRepository extends JpaRepository<Note, Long>
- Schema managed by Flyway migrations (V1 creates table
note
)
CRUD operations:
- Create (
add
) - Read (
getById
,getAll
) - Update (
update(Note note)
) - Delete (
deleteById
)
NoteController
routes:
GET /note/list
— list notesGET /note/create
— show create formPOST /note/create
— create noteGET /note/edit?id=123
— show edit form (id in query)POST /note/edit
— update note (id + fields in body)POST /note/delete
— delete note (id in body)
templates/note/list.html
templates/note/create.html
templates/note/edit.html