Coder Social home page Coder Social logo

springbook's Introduction

Spring Book - Example

BUGS: habuma/spring-in-action-5-samples#40

Initializing

  1. Initializing spring project on start.spring.io

  2. Initializing Git Repository and Push to remote

    1. Initialize local:
      https://www.youtube.com/watch?v=hks47h4C_nY
      https://www.youtube.com/watch?v=bvl4Kbe-qok
    2. Initialize remote: push and commit
  3. Spring Tools 4

Project structure

TODO / Testing

  • Add missing unit tests

Testing:

Remarks

Chapter 1

Controller

"GetMapping cannot be resolved to a type":

Bug in test for HomeController ...import org.junit.Test could not be resolved:

Chapter 2

Lombock installation Problems:

  1. Download lombok.jar
  2. sudo java -jar lombok.jar
  3. manually set eclipse path: /snap/eclipse/48/ Still not working!

General

  • Model - View

  • Model - View-Bibliothek

  • Request Mapping / GetMapping

  • Beans

Thymleaf

https://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html
https://www.thymeleaf.org/doc/articles/standarddialect5minutes.html

Logging

(Java book p.930)

  • JUL: java.util.logging

Validations

  • @NotNull
  • @Size(min=..., message="...")
  • @NotBlank
  • @Pattern
  • @Digits
  • @CreditCardNumber (Hibernate)

Problem: Needed to add to pom.xml:

Solution: https://www.baeldung.com/javax-validation

<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>

Problem: Error Message now shown, instead: Whitelabel Error Page

Solution: http://forum.thymeleaf.org/Fields-object-functions-Spring-td3302513.html

Problem: Validation evaluation not working with taco design page!!! MAASSIV Error if not enough ingredients choosen?!? WTF Fucked-up-beyond-believe bullshit useles error message!

Solution: NONE

View-Controller

(p. 55)

????

Chapter 3

Goal:

  • Use Jdbc Template from Spring
  • Insert data with SimpleJbcInsert
  • Declare JPA-Repositories with Spring Data

Add dependency

    <dependency>
    	<groupId>org.springframework.boot</groupId>
    	<artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>

H2 Database

https://www.youtube.com/watch?v=8QBJMxyXIqc https://howtodoinjava.com/spring-boot2/h2-database-example/
https://www.youtube.com/watch?v=8QBJMxyXIqc

  • http://localhost:8080/h2-console/
  • URL: jdbc:h2:mem:testdb

Remarks

General

  • Domain Driven Design
  • Repositories
  • JPA / JDBC

Annotations / methods

  • @Autowired
  • @Repository
  • jdbc.query queryForObject

**H2 / Hibernate **

  • schema.sql ...for creating database-schema
  • data.spl ...for populating database automatically by spring
  • SQL Statements:
    • CREATE TABLE IF NOT EXITS (...NOT NULL)
    • ALTER TABLE ...ADD FOREIGN KEY...REFERENCES
    • DELETE FROM
    • DELETE FROM .. WHERE ...
    • CREATE TABLE ... IF NOT EXISTS

JdbcTemplate

  • "query"
  • "queryForObject"
  • "update"
  • PreparedStatementCreator
  • KeyHolder

Java / Spring

  • Converter ... to convert string-to-object for change that ingredients come from database instead hardcodet; auto-registration in Spring (Boot?) (see "Problems")

Links

JDBC

Converter

Problems

####CONVERTER
..."when private List ingredients; was private List ingredients; it worked, but now it must be private List ingredients; because of the way it is saved in the database but it breaks at this point, how to fix it?" https://stackoverflow.com/questions/55093954/thymeleaf-failed-to-convert-property-value-of-type-java-lang-string-to-required/63328365#63328365

Keyholder - NullPointerException
habuma/spring-in-action-5-samples#40 http://mkaroune.e-monsite.com/pages/keyholder-getkey-return-null.html

Solution

order.tacos

... List property of "order" class not saved from design to order forms! So wont be stored in database!?!

springbook's People

Contributors

oliverzott avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.