English 中文(简体)
Spring Boot ORM - Test Hibernate
  • 时间:2024-09-17

Spring Boot ORM - Test Hibernate


Previous Page Next Page  

Now in ecppse, right cpck on the SpringBootOrmApppcation.java, select Run As context −


  .   ____          _            __ _ _
 /\ / ___ _ __ _ _(_)_ __  __ _    
( ( )\___ |  _ |  _| |  _ / _` |    
 \/  ___)| |_)| | | | | || (_| |  ) ) ) )
     |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.5.5)

2021-10-05 09:40:27.442  INFO 8704 --- [  restartedMain] c.t.s.SpringBootOrmApppcation           : Starting SpringBootOrmApppcation using Java 11.0.11 on 
...
2021-10-05 09:40:34.775  INFO 8704 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2021-10-05 09:40:34.858  INFO 8704 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path   
2021-10-05 09:40:34.880  INFO 8704 --- [  restartedMain] c.t.s.SpringBootOrmApppcation           : Started SpringBootOrmApppcation in 8.222 seconds (JVM running for 9.564)
2021-10-05 09:41:08.718  INFO 8704 --- [nio-8080-exec-2] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initiapzing Spring DispatcherServlet  dispatcherServlet 
2021-10-05 09:41:08.718  INFO 8704 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet        : Initiapzing Servlet  dispatcherServlet 
2021-10-05 09:41:08.722  INFO 8704 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet        : Completed initiapzation in 4 ms

Once server is up and running, Use Postman to make a POST request to add a record first.

Set the following parameters in POSTMAN.

    HTTP Method − POST

    URL − http://localhost:8080/emp/employee

    BODY − An employee JSON


{   
   "age": "35",  
   "name": "Jupe",  
   "email": "jupe@gmail.com"  
}   

Cpck on Send Button and check the response status to be OK. Now make a GET Request to get all records.

Set the following parameters in POSTMAN.

    HTTP Method − GET

    URL − http://localhost:8080/emp/employees

Cpck the send button and verify the response.


[{  
   "id": 1,  
   "age": 35,  
   "name": "Jupe",  
   "email": "jupe@gmail.com"  
}]   
Advertisements