当前位置: 首页 > news >正文

阿里云企业网站搭建微信视频制作小程序

阿里云企业网站搭建,微信视频制作小程序,网站最近收录,wordpress seo 链接我们之前的设置可以正常工作。 我们现在要做的是进一步发展#xff0c;并配置两个单独的实体管理器#xff0c;而不会影响我们之前实现的功能。 第一步是将默认的实体管理器配置设置为主要配置。 这是第一步 package com.gkatzioura.springdatareadreplica.config; import… 我们之前的设置可以正常工作。 我们现在要做的是进一步发展并配置两个单独的实体管理器而不会影响我们之前实现的功能。 第一步是将默认的实体管理器配置设置为主要配置。 这是第一步 package com.gkatzioura.springdatareadreplica.config; import javax.sql.DataSource; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; Configuration public class PrimaryEntityManagerConfiguration { Value ( ${spring.datasource.username} ) private String username; Value ( ${spring.datasource.password} ) private String password; Value ( ${spring.datasource.url} ) private String url; Bean Primary public DataSource dataSource() throws Exception { return DataSourceBuilder.create() .url(url) .username(username) .password(password) .driverClassName( org.postgresql.Driver ) .build(); } Bean Primary public LocalContainerEntityManagerFactoryBean entityManagerFactory( EntityManagerFactoryBuilder builder, Qualifier ( dataSource ) DataSource dataSource) { return builder.dataSource(dataSource) .packages( com.gkatzioura.springdatareadreplica ) .persistenceUnit( main ) .build(); } } 如果您使用此配置运行您的应用程序它将像之前的应用程序一样运行。 现在是时候配置只读实体管理器了。 package com.gkatzioura.springdatareadreplica.config; import javax.sql.DataSource; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Primary; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; Configuration public class ReadOnlyEntityManagerConfiguration { Value ( ${spring.datasource.username} ) private String username; Value ( ${spring.datasource.password} ) private String password; Value ( ${spring.datasource.readUrl} ) private String readUrl; Bean public DataSource readDataSource() throws Exception { return DataSourceBuilder.create() .url(readUrl) .username(username) .password(password) .driverClassName( org.postgresql.Driver ) .build(); } Bean public LocalContainerEntityManagerFactoryBean readEntityManagerFactory( EntityManagerFactoryBuilder builder, Qualifier ( readDataSource ) DataSource dataSource) { return builder.dataSource(dataSource) .packages( com.gkatzioura.springdatareadreplica ) .persistenceUnit( read ) .build(); } } 另外我将向控制器添加方法以保存模型。 package com.gkatzioura.springdatareadreplica.controller; import java.util.List; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; import com.gkatzioura.springdatareadreplica.entity.Employee; import com.gkatzioura.springdatareadreplica.repository.EmployeeRepository; RestController public class EmployeeContoller { private final EmployeeRepository employeeRepository; public EmployeeContoller(EmployeeRepository employeeRepository) { this .employeeRepository employeeRepository; } GetMapping ( /employee ) public ListEmployee getEmployees() { return employeeRepository.findAll(); } PostMapping ( /employee ) ResponseStatus (HttpStatus.CREATED) ResponseStatus (HttpStatus.CREATED) public void addEmployee( RequestBody Employee employee) { employeeRepository.save(employee); } } 如果您确实尝试使用控制器添加员工然后查询读取的数据库您将看到根本没有添加任何条目。 因此我们已经启动并运行了主要的实体管理器而我们也有辅助的实体管理器。 第二个尚未使用。 下一个博客着重于使用辅助只读实体管理器。 翻译自: https://www.javacodegeeks.com/2019/10/read-replicas-and-spring-data-configuring-two-entity-managers.html
http://www.huolong8.cn/news/325830/

相关文章:

  • 网站后端开发流程推广系统
  • 做图哪个网站素材多太仓手机网站建设
  • 福田专业网站建设公司哪家好河北邯郸是几线城市
  • 网站建设新技术品牌商城网站制作
  • 学做网站论坛全部视频注册传媒公司需要的条件
  • 微信网站开发 全屏昌黎网站建设
  • 青岛做网站优化的公司开源php企业网站
  • 蓬莱网站建设哪家好wordpress哪里找域名
  • 网站建设自主开发的三种方式使用wampserver做响应式网站
  • 哪家网站建设最好做网站的公司怎么做业务
  • 做网站的案例工厂展厅效果图
  • 什么网站了解国家建设的行情网站开发哪家公司
  • 网站建设公司经营范围做ppt需要知道网站
  • 网站开发一键上架淘宝wordpress用户前台积分
  • 手机房产网站模板鄂尔多斯网站制作公司
  • 手机网站淘宝客怎么做网站开发 博客
  • wordpress多站点插件个人博客网站怎么赚钱
  • 装饰行业模板网站怎样做才能让网站帮忙送东西
  • 合肥新格建站网济南哪里有做网站的
  • 小米手表网站阿里云官网首页
  • 网站 接入微信手机端怎么刷排名
  • 可以自己做网站做宣传吗男孩子怎么做网站
  • 零基础月做网站多久小白一步步做网站
  • 项目网站建设方案模板公司网站的宣传栏怎么做
  • 教育培训机构招生网站建设网站规划是什么意思
  • 营销手机网站制作asp网站打开速度慢
  • 网站推广多少钱河北seo网站优化电话
  • 锦州公司做网站轻云服务器菁英版 多个网站
  • asp网站500错误iis7仁怀哪儿做网站
  • 优秀品牌网站案例分析wordpress连接失效