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

建设银行河北省分行官方网站河池网络推广

建设银行河北省分行官方网站,河池网络推广,网站后台管理模板免费下载,psd网站首页图片前些天发现了一个巨牛的人工智能学习网站#xff0c;通俗易懂#xff0c;风趣幽默#xff0c;忍不住分享一下给大家。点击跳转到教程。 一.什么是spring boot Takes an opinionated view of building production-ready Spring applications. Spring Boot favors convention…前些天发现了一个巨牛的人工智能学习网站通俗易懂风趣幽默忍不住分享一下给大家。点击跳转到教程。 一.什么是spring boot Takes an opinionated view of building production-ready Spring applications. Spring Boot favors convention over configuration and is designed to get you up and running as quickly as possible. 摘自官网 翻译采纳了建立生产就绪Spring应用程序的观点。 Spring Boot优先于配置的惯例旨在让您尽快启动和运行。 spring boot 致力于简洁让开发者写更少的配置程序能够更快的运行和启动。它是下一代javaweb框架并且它是spring cloud微服务的基础。 二、搭建第一个sping boot 程序 可以在start.spring.io上建项目也可以用idea构建。本案列采用idea. 具体步骤 new prpject - spring initializr -{name :firstspringboot , type: mavenproject,packaging:jar ,..}  -{spring version :1.5.2  web: web } - ... 应用创建成功后会生成相应的目录和文件。 其中有一个Application类,它是程序的入口: SpringBootApplication public class FirstspringbootApplication {public static void main(String[] args) {SpringApplication.run(FirstspringbootApplication.class, args);} } 在resources文件下下又一个application.yml文件它是程序的配置文件。默认为空写点配置 ,程序的端口为8080,context-path为 /springboot server:port: 8080context-path: /springboot 写一个HelloController RestController     //等同于同时加上了Controller和ResponseBody public class HelloController {//访问/hello或者/hi任何一个地址都会返回一样的结果RequestMapping(value {/hello,/hi},method RequestMethod.GET)public String say(){return hi you!!!;} } 运行 Application的main(),呈现会启动由于springboot自动内置了servlet容器所以不需要类似传统的方式先部署到容器再启动容器。只需要运行main()即可这时打开浏览器输入网址localhost:8080/springboot/hi 就可以在浏览器上看到: hi you!!! 三.属性配置 在appliction.yml文件添加属性 server:port: 8080context-path: /springbootgirl:name: Bage: 18content: content:${name},age:${age} 在java文件中获取name属性如下 Value(${name})private String name; 也可以通过ConfigurationProperties注解将属性注入到bean中通过Component注解将bean注解到spring容器中 ConfigurationProperties(prefixgirl) Component public class GirlProperties {private String name;private int age;public String getName() {return name;}public void setName(String name) {this.name name;}public int getAge() {return age;}public void setAge(int age) {this.age age;} } 另外可以通过配置文件制定不同环境的配置文具体见源码 spring:profiles:active: prod 四.通过jpa方式操作数据库 导入jar 在pom.xml中添加依赖: dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-data-jpa/artifactId/dependencydependencygroupIdmysql/groupIdartifactIdmysql-connector-java/artifactId/dependency 在appilication.yml中添加数据库配置 spring:profiles:active: proddatasource:driver-class-name: com.mysql.jdbc.Driverurl: jdbc:mysql://localhost:3306/dbgirl?useUnicodetruecharacterEncodingutf8characterSetResultsutf8username: rootpassword: 123jpa:hibernate:ddl-auto: createshow-sql: true 这些都是数据库常见的一些配置没什么可说的其中ddl_auto: create 代表在数据库创建表update 代表更新首次启动需要create ,如果你想通过hibernate 注解的方式创建数据库的表的话之后需要改为 update. 创建一个实体girl这是基于hibernate的: Entity public class Girl {IdGeneratedValueprivate Integer id;private String cupSize;private Integer age;public Girl() {}public Integer getId() {return id;}public void setId(Integer id) {this.id id;}public Integer getAge() {return age;}public void setAge(Integer age) {this.age age;}public String getCupSize() {return cupSize;}public void setCupSize(String cupSize) {this.cupSize cupSize;} } 创建Dao接口, springboot 将接口类会自动注解到spring容器中不需要我吗做任何配置只需要继承JpaRepository 即可 //其中第二个参数为Id的类型 public interface GirlRep extends JpaRepositoryGirl,Integer{} 创建一个GirlController写一个获取所有girl的api和添加girl的api 自己跑一下就可以了: RestController public class GirlController {Autowiredprivate GirlRep girlRep;/*** 查询所有女生列表* return*/RequestMapping(value /girls,method RequestMethod.GET)public ListGirl getGirlList(){return girlRep.findAll();}/*** 添加一个女生* param cupSize* param age* return*/RequestMapping(value /girls,method RequestMethod.POST)public Girl addGirl(RequestParam(cupSize) String cupSize,RequestParam(age) Integer age){Girl girl new Girl();girl.setAge(age);girl.setCupSize(cupSize);return girlRep.save(girl);}}  如果需要事务的话在service层加Transaction注解即可。已经凌晨了我要睡了. 源码http://download.csdn.net/detail/forezp/9778235 参考资料 说明本文部分内容均来自慕课网。慕课网http://www.imooc.com 廖师兄   转自方志朋的博客 https://www.fangzhipeng.com/springboot/2017/05/25/sb25-2hour.html
http://www.yutouwan.com/news/121196/

相关文章:

  • 苏州城乡建设局的网站做网站公司怎么找客户
  • 中国建筑装饰工程有限公司网页的优化与发布
  • 网站 多个ip 备案做网站的框架
  • 中信建设有限责任公司集采优化是企业通过网站来做吗
  • 有品质的网站推广公司深圳网站制作公司排名
  • 公司网站怎么自己做wordpress分类
  • 松花江避暑城建设网站网站白名单查询
  • 网站备案怎么查商丘网站建设
  • 如何建立本站站点360营销
  • 2018年怎么做网站排名赶集网网站建设分析
  • 小型网站制作做网站 超速云
  • 做餐饮系统网站建设融资平台有哪些
  • wordpress vps建站做网站怎么买断源码
  • 正规东莞网站建设邯郸做移动网站报价
  • 网站建设怎么设置权限页面设计费用
  • 公众号 手机网站开发个人如何做网页
  • 云浮北京网站建设建设银行网站明细多长时间
  • 高平网站优化公司图像生成器在线制作
  • 网站建设公司哪家好 搜搜磐石网络网推公司干什么的
  • 网站开发行业资讯视频制作软件pr
  • 阜阳建网站网络策划公司
  • 温州专业手机网站制作哪家好网站后台管理系统怎么进
  • 电子商务他们的代表网站西安做网站建设哪家好
  • wordpress能做图片站百度新闻首页新闻全文
  • 建设网站基本流程wordpress子 主题
  • 怎样做国外能看到的网站怎么制作网站在线人数
  • 大连制作网站报价用wordpress编写网站
  • 企业网站 asp php山西建设公司网站
  • 东莞网站建设什么价格便宜h5建站工具
  • 禅城区企业网站建设wordpress 视频模板