Spring Boot ORM - 测试项目



现在在 STS 中,右键单击 springbootorm 项目,选择 在 Run As -> Spring Boot 应用程序中运行 上下文 -

Run As Spring Boot App

输出

您将在 STS 控制台中看到类似的结果。

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/

[32m :: Spring Boot :: [39m              [2m (v3.3.3)[0;39m

[2m2024-08-28T15:38:41.453+05:30[0;39m [32m INFO[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36mc.t.s.SpringbootormApplication          [0;39m [2m:[0;39m Starting SpringbootormApplication using Java 21.0.3 with PID 4760 (E:\springbootorm\target\classes started by Tutorialspoint in E:\springbootorm)
[2m2024-08-28T15:38:41.456+05:30[0;39m [32m INFO[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36mc.t.s.SpringbootormApplication          [0;39m [2m:[0;39m No active profile set, falling back to 1 default profile: "default"
[2m2024-08-28T15:38:41.517+05:30[0;39m [32m INFO[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36m.e.DevToolsPropertyDefaultsPostProcessor[0;39m [2m:[0;39m Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
[2m2024-08-28T15:38:41.517+05:30[0;39m [32m INFO[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36m.e.DevToolsPropertyDefaultsPostProcessor[0;39m [2m:[0;39m For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
[2m2024-08-28T15:38:42.164+05:30[0;39m [32m INFO[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36m.s.d.r.c.RepositoryConfigurationDelegate[0;39m [2m:[0;39m Bootstrapping Spring Data JPA repositories in DEFAULT mode.
[2m2024-08-28T15:38:42.214+05:30[0;39m [32m INFO[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36m.s.d.r.c.RepositoryConfigurationDelegate[0;39m [2m:[0;39m Finished Spring Data repository scanning in 43 ms. Found 1 JPA repository interface.
[2m2024-08-28T15:38:42.781+05:30[0;39m [32m INFO[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36mo.s.b.w.embedded.tomcat.TomcatWebServer [0;39m [2m:[0;39m Tomcat initialized with port 8080 (http)
[2m2024-08-28T15:38:42.797+05:30[0;39m [32m INFO[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36mo.apache.catalina.core.StandardService  [0;39m [2m:[0;39m Starting service [Tomcat]
[2m2024-08-28T15:38:42.797+05:30[0;39m [32m INFO[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36mo.apache.catalina.core.StandardEngine   [0;39m [2m:[0;39m Starting Servlet engine: [Apache Tomcat/10.1.28]
[2m2024-08-28T15:38:42.848+05:30[0;39m [32m INFO[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36mo.a.c.c.C.[Tomcat].[localhost].[/]      [0;39m [2m:[0;39m Initializing Spring embedded WebApplicationContext
[2m2024-08-28T15:38:42.848+05:30[0;39m [32m INFO[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36mw.s.c.ServletWebServerApplicationContext[0;39m [2m:[0;39m Root WebApplicationContext: initialization completed in 1330 ms
[2m2024-08-28T15:38:42.969+05:30[0;39m [32m INFO[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36mcom.zaxxer.hikari.HikariDataSource      [0;39m [2m:[0;39m HikariPool-1 - Starting...
[2m2024-08-28T15:38:43.457+05:30[0;39m [32m INFO[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36mcom.zaxxer.hikari.pool.HikariPool       [0;39m [2m:[0;39m HikariPool-1 - Added connection com.mysql.cj.jdbc.ConnectionImpl@3c6da728
[2m2024-08-28T15:38:43.459+05:30[0;39m [32m INFO[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36mcom.zaxxer.hikari.HikariDataSource      [0;39m [2m:[0;39m HikariPool-1 - Start completed.
[2m2024-08-28T15:38:43.504+05:30[0;39m [32m INFO[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36mo.hibernate.jpa.internal.util.LogHelper [0;39m [2m:[0;39m HHH000204: Processing PersistenceUnitInfo [name: default]
[2m2024-08-28T15:38:43.564+05:30[0;39m [32m INFO[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36morg.hibernate.Version                   [0;39m [2m:[0;39m HHH000412: Hibernate ORM core version 6.5.2.Final
[2m2024-08-28T15:38:43.600+05:30[0;39m [32m INFO[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36mo.h.c.internal.RegionFactoryInitiator   [0;39m [2m:[0;39m HHH000026: Second-level cache disabled
[2m2024-08-28T15:38:43.934+05:30[0;39m [32m INFO[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36mo.s.o.j.p.SpringPersistenceUnitInfo     [0;39m [2m:[0;39m No LoadTimeWeaver setup: ignoring JPA class transformer
[2m2024-08-28T15:38:44.909+05:30[0;39m [32m INFO[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36mo.h.e.t.j.p.i.JtaPlatformInitiator      [0;39m [2m:[0;39m HHH000489: No JTA platform available (set 'hibernate.transaction.jta.platform' to enable JTA platform integration)
Hibernate: create table employee (id integer not null auto_increment, age integer not null, email varchar(255), name varchar(255), primary key (id)) engine=InnoDB
[2m2024-08-28T15:38:45.141+05:30[0;39m [32m INFO[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36mj.LocalContainerEntityManagerFactoryBean[0;39m [2m:[0;39m Initialized JPA EntityManagerFactory for persistence unit 'default'
[2m2024-08-28T15:38:45.431+05:30[0;39m [33m WARN[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36mJpaBaseConfiguration$JpaWebConfiguration[0;39m [2m:[0;39m 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
[2m2024-08-28T15:38:45.862+05:30[0;39m [32m INFO[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36mo.s.b.d.a.OptionalLiveReloadServer      [0;39m [2m:[0;39m LiveReload server is running on port 35729
[2m2024-08-28T15:38:45.901+05:30[0;39m [32m INFO[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36mo.s.b.w.embedded.tomcat.TomcatWebServer [0;39m [2m:[0;39m Tomcat started on port 8080 (http) with context path '/'
[2m2024-08-28T15:38:45.909+05:30[0;39m [32m INFO[0;39m [35m4760[0;39m [2m---[0;39m [2m[springbootorm] [  restartedMain][0;39m [2m[0;39m[36mc.t.s.SpringbootormApplication          [0;39m [2m:[0;39m Started SpringbootormApplication in 4.891 seconds (process running for 5.804)

添加一个员工

一旦服务器启动并正在运行,使用 Postman 发送 POST 请求以首先添加一条记录。

在 POSTMAN 中设置以下参数。

  • HTTP 方法 - POST

  • URL - https://:8080/emp/employee

  • 正文 - 一个员工 JSON

{   
   "age": "35",  
   "name": "Julie",  
   "email": "julie@gmail.com"  
}   

单击发送按钮,并检查响应状态是否为 OK。

Add an Employee

获取所有员工

现在发送一个 GET 请求以获取所有记录。

在 POSTMAN 中设置以下参数。

  • HTTP 方法 - GET

  • URL - https://:8080/emp/employees

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

[{  
   "id": 1,  
   "age": 35,  
   "name": "Julie",  
   "email": "julie@gmail.com"  
}]   
Get all Employees
广告
© . All rights reserved.