SpringCloud database connection debug

Jerry Wang 2021-02-23 18:20:09
springcloud database connection debug

Created by Wang, Jerry, last modified on Aug 08, 2016

The environment variable VCAP_SERVICES is used by Cloud Foundry to provide access information to all backing services, including database connection information to microservices. With this information, and the following plugins making use of it, a database connection can be created and used. Locally we configure this same environment variable so that a dedicated database can be used for local tests.

We use the CloudDatabaseConfig file to configure access to a database. Starting with the information provided in the environment variable VCAP_SERVICES , we end up with an instance of a CRUD repository. For this the three plugins are used, which are explained in detail below. As the CloudDatabaseConfig class is registered in the ContextListener class, also the beans defined using methods annotated with @Bean are registered in the context.


EclipseLink is used as a JPA implementation. JPA/EclipseLink is used to map from Java classes to database tables (and from Java data types to SQL data types). SQL queries, result set handling, and object conversion are managed and optimized by JPA/EclipseLink. Applications using EclipseLink are portable to supported SQL databases with little performance overhead. An alternative to EclipseLink is Hibernate (also see this discussion).

EclipseLink needs access to a database, which we provide using the DataSource instance of the previous step. Using this database connection, the JPA object instances (EntityManager and TransactionManager) are provided. This is done with the following code, where most functionality is part of EntityManagerFactoryProvider. Again, the two defining methods are annotated with @Bean so that the corresponding beans are registered automatically.

Participation of this paper Tencent cloud media sharing plan , You are welcome to join us , share .

本文为[Jerry Wang]所创,转载请带上原文链接,感谢

  1. JAVA的函数式接口
  2. JAVA里的元祖类
  3. JQuery Gantt package to create a new ASP.NET project
  4. Binary conversion of Unicode code (Java)
  5. The functional interface of Java
  6. Yuanzu class in Java
  7. Java中的CPU占用高和内存占用高的问题排查
  8. HashMap连环问你能答出几道?
  9. IntelliJ IDEA 还能画思维导图,果然最强 IDE!
  10. java中的反射和代理
  11. Troubleshooting of high CPU and memory usage in Java
  12. How many questions can you answer?
  13. IntelliJ idea can also draw mind maps. It's really the strongest ide!
  14. Reflection and proxy in Java
  15. Java中的CPU占用高和内存占用高的问题排查
  16. Linux OOM(out of memory)
  17. mysql 自定义函数因参数名称报错
  18. Troubleshooting of high CPU and memory usage in Java
  19. Linux OOM(out of memory)
  20. MySQL user defined function error due to parameter name
  21. echarts-gl 3D 地图柱状图可视化GDP
  22. Visualization of histogram of ecarts GL 3D map
  23. 金三银四如何应对Redis面试,一文深入Redis实战实践!
  24. 阿里资深架构师定制金三银四面试整理出来的一份Java核心知识点.pdf
  25. 为什么Java开发工程师工资高,却很多人想转行?
  26. How to deal with the interview of redis!
  27. Ali senior architect customizes a Java core knowledge point sorted out in the interview of golden, silver and four.pdf
  28. Why do java development engineers have high salaries, but many people want to change careers?
  29. 用注解开发SpringMVC
  30. Developing spring MVC with annotations
  31. 编译redis报错/deps/hiredis/libhiredis.a解决
  32. Compile redis report error / DEPs / hirredis / libhirredis. A solution
  33. 用注解开发SpringMVC
  34. Developing spring MVC with annotations
  35. Spring学习笔记-01
  36. Centos安装和卸载docker
  37. Spring learning notes-01
  38. Installing and uninstalling docker in CentOS
  39. Java基础-异常
  40. Java基础-反射
  41. Java基础-继承
  42. k8s部署 (进行中)
  43. Hive-常见调优方式 && 两个面试sql
  44. 死磕Spring之IoC篇 - BeanDefinition 的加载阶段(XML 文件)
  45. Java basics exception
  46. Java Basics - Reflection
  47. Java Basics - inheritance
  48. K8s deployment (in progress)
  49. Hive common tuning methods & two interview SQL
  50. The loading phase of beandefinition (XML file)
  51. 死磕Spring之IoC篇 - BeanDefinition 的加载阶段(XML 文件)
  52. Hive-常见调优方式 && 两个面试sql
  53. The loading phase of beandefinition (XML file)
  54. Hive common tuning methods & two interview SQL
  55. iconv文件编码转换由windows文件放到linux下
  56. The code conversion of iconv file is put into Linux by windows file
  57. SpringBoot2+intellij IDEA开发前环境准备
  58. Preparation of pre development environment for springboot2 + IntelliJ idea
  59. Docker私有仓库部署
  60. Docker private warehouse deployment