Spring Boot ORM - 测试 EclipseLink

现在在 Eclipse 中,右键单击 SpringBootOrmApplication.java,选择 Run As 上下文菜单,然后选择 Java Application。 检查eclipse中的控制台日志。 您可以看到以下日志 −



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

...
2021-10-06 09:52:28.187  INFO 10048 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3111 ms
...
[EL Info]: 2021-10-06 09:52:29.063--ServerSession(2026366076)--Thread(Thread[restartedMain,5,main])--EclipseLink, version: Eclipse Persistence Services - 2.7.8.v20201217-ecdf3c32c4
...
[EL Config]: connection: 2021-10-06 09:52:29.424--ServerSession(2026366076)--Connection(460137428)--Thread(Thread[restartedMain,5,main])--Connected: jdbc:mysql://localhost:3306/tutorialspoint?useSSL=false&allowPublicKeyRetrieval=true
	User: root@localhost
	Database: MySQL  Version: 8.0.23
	Driver: MySQL Connector/J  Version: mysql-connector-java-8.0.26 (Revision: 9aae1e450989d62c06616c1dcda3e404ef84df70)
[EL Fine]: connection: 2021-10-06 09:52:29.471--ServerSession(2026366076)--Thread(Thread[restartedMain,5,main])--/file:/F:/tutorialspoint/springbootorm/target/classes/_default login successful
[EL Finer]: metamodel: 2021-10-06 09:52:29.512--ServerSession(2026366076)--Thread(Thread[restartedMain,5,main])--Canonical Metamodel class [com.tutorialspoint.springbootorm.entity.Employee_] not found during initialization.
2021-10-06 09:52:29.796  WARN 10048 --- [  restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2021-10-06 09:52:30.543  INFO 10048 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2021-10-06 09:52:30.603  INFO 10048 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2021-10-06 09:52:30.622  INFO 10048 --- [  restartedMain] c.t.s.SpringBootOrmApplication           : Started SpringBootOrmApplication in 6.556 seconds (JVM running for 7.512)
2021-10-06 09:53:38.526  INFO 10048 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2021-10-06 09:53:38.527  INFO 10048 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2021-10-06 09:53:38.532  INFO 10048 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 5 ms

服务器启动并运行后,使用 Postman 发出 GET 请求以获取所有记录。

在 POSTMAN 中设置以下参数。

  • HTTP Method − GET

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

单击发送按钮并验证响应。


[{  
   "id": 1,  
   "age": 35,  
   "name": "Julie",  
   "email": "julie@gmail.com"  
}]