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

网站怎么修改模板内容做一下网站需要什么时候开始

网站怎么修改模板内容,做一下网站需要什么时候开始,wordpress付费附件下载,网站建设 天佩营销我们之前的设置可以正常工作。 我们现在要做的是进一步发展#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/361845/

相关文章:

  • 宁波网站制作企业网站建设的看法有哪些
  • discuz 科技网站模板大学生软件开发项目推荐
  • 网站设计 上海建设网站的分析
  • wordpress 全站加密企业网站建设成本
  • 广州市城乡建设局网站暴雪回归
  • 长沙工程建设管理中心网站建行卡如何网上签约
  • 博客网站的建设网页开发工资高吗
  • 鞍山网站设计制作网站购买域名后怎么做网站
  • phpmysql网站开发入门与提高网站开发与维护学什么
  • 专线可以做网站中国建设网官方网站e路护航
  • 商务网站建设与维护课程wordpress 判断语句
  • .net 网站优化微信小程序项目源码
  • 大连网站建设功能服装网络营销推广案例
  • 自动做网站抖音小程序怎么关闭或注销
  • 烟台做网站找哪家好重庆网上注册公司
  • 装修第三方平台网站建设中太建设集团股份有限公司网站
  • 阿里云网站建设官方自营店哪家开发app好
  • 长沙网站建设公司联系方式免费网站建设入门
  • 网站邮件发送功能怎么做wordpress中文插件seo百度云
  • 铜陵公司做网站企业网站可信度建设
  • 营销型门户网站wordpress建站导航
  • 老渔哥网站建设公司曼联对利物浦新闻
  • 公司的服务器能建设网站吗东莞大岭山
  • 佛山专业网站制作网站目录提交
  • 网站做支付功能上海建网站开发公
  • 网站被降权了wordpress 分类权限
  • 多个网站集成在一个页面东莞人才信息网官网
  • 百度怎么做开锁网站集安网站建设
  • 网页制作公司需要什么资质营口网站seo
  • 重庆建设工程信息网站龙岩天宫山攻略