I created a springboot app with idea community, my steps:

  1. create an empty maven peoject, main dependencies used are, remember, the version for parent and spring-boot should be the same, or else, it might throw exception.

org.springframework.bootspring-boot-starter-parent2.3.1.RELEASEorg.springframework.bootspring-boot-starter-weborg.springframework.bootspring-boot2.3.1.RELEASE

2. create an entry app class for springboot, and a controller, add folder structure, 

image.png,

3. run profile, mvn spring-boot:run

image.png

4. controller

springboot1.controllersorg.springframework.web.bind.annotation.org.springframework.web.bind.annotation.FrontController {

    ()
    String () {
        }
}


5. it's OK to run now, and the 

image.png

6. Break point can't hit here in idea IDE, it requires this spring-boot maven plugin to hit breakpoints, just add to pom.xml root el this build section, and re-debug, breakpoint is hit now.

org.springframework.bootspring-boot-maven-pluginfalse


image.png

7. receiving the path variable, with route template, or using /users?name=me to get from request

image.png

8. adding a scratch file and watch hashmap object compare 

image.png

9. Hashmap key compare based on hashCode, in above picture, size is 2, here override the hashcode method, when putting and keys have same hashcode, value will be updated, here 1.

image.png

10. But in java, hashmap first uses equals method to determine whether a same key already exists, then regarding put operation, it uses the hashcode method. The size will be 2, if putting 2 objects having same hashcode. Below size is 1, though they have different model.

image.png

没有登录不能评论