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

高端网站建设 南京东营网站制作方案

高端网站建设 南京,东营网站制作方案,搭建简单的网站,宁夏建设监理协会网站哈喽#xff0c;大家好#xff0c;我是有勇气的牛排#xff08;全网同名#xff09;#x1f42e; 有问题的小伙伴欢迎在文末评论#xff0c;点赞、收藏是对我最大的支持#xff01;#xff01;#xff01;。 前言 SpringBoot是基于Spring开发的开源项目#xff0c…哈喽大家好我是有勇气的牛排全网同名 有问题的小伙伴欢迎在文末评论点赞、收藏是对我最大的支持。 前言 SpringBoot是基于Spring开发的开源项目属于快速开发框架封装了常用的依赖能够快速整合第三方框架简化了xml配置并且去全部采用注解的方式内置Tomcat、Jetty、Undertow等默认集成SpringMVC框架。 1 创建Maven项目 maven配置 !-- SpringBoot依赖配置 -- !-- parent指定版本 -- parentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion2.1.8.RELEASE/version /parent dependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependency/dependencies2 HelloWorld package com.couragesteak.service;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;RestController EnableAutoConfiguration public class HelloWorldService {// http://127.0.0.1:8080/helloRequestMapping(/hello)public String index() {return 你好有勇气的牛排;}public static void main(String[] args) {SpringApplication.run(HelloWorldService.class, args);} } 2.1 RequestController与 Controller RequestController 由 SpringMVC提供相当于在每个方法添加ResponseBody注解。 如果在类上加 RequestController该类中所有 SpringMVC接口映射均返回json格式。 2.2 主类定义 App.java package com.couragesteak; /** Author : 有勇气的牛排* FileName: APP.java* desc : 启动* */import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;SpringBootApplication public class App {public static void main(String[] args) {SpringApplication.run(App.class, args);}/** ComponentScan 扫包范围* 当前启动类同级包或者子包* */ }3 项目目录架构 com.couragesteak.controller视图层web和接口(业务逻辑) com.couragesteak.service业务逻辑层 com.couragesteak.dao数据访问层 3.1 静态资源 springboot默认静态资源目录位于 classpath(resource)下目录名需要符合如下规则 /static /public /resource /META-INF/resources 4.2 配置文件 4.2.1 yml类型推荐与 properties 位置/resource/application.yml cs:name: csstar: 999位置/resource/application.properties #cs.namecouragesteak #cs.star9ReadConfigService.java /** Author : 有勇气的牛排* FileName: ReadConfigService.java* desc : 读取配置* */package com.couragesteak.service;import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;RestController public class ReadConfigService {Value(${cs.name})private String name;Value(${cs.star})private String star;//RequestMapping(/getProperties)public String getProperties() {return name : star;} }4.2.2 yaml中文件占位符 在SpringBoot的配置文件中我们可以使用SpringBoot提供的的一些随机数,来制定找不到属性时的默认值 random.value、{random.value}、random.value、{random.int}、${random.long} random.int(10)、{random.int(10)}、random.int(10)、{random.int[1024,65536]} -${app.name:默认值} 4.2.3 多环境配置 application.yml spring:profiles:active: dev # active: test # active: prdapplication-dev.yml开发环境 cs:name: 有勇气的牛排star: 9age: ${radom.int(10)}spring:http:encoding:force: true### 模版引擎编码为UTF-8charset: UTF-8# 模板freemarker:allow-request-override: falsecache: falsecheck-template-location: truecharset: UTF-8content-type: text/html; charsetutf-8expose-request-attributes: falseexpose-session-attributes: falseexpose-spring-macro-helpers: false## 模版文件结尾.ftlsuffix: .ftl## 模版文件目录template-loader-path: classpath:/templates# 模板thymeleaf:#prefix指定模板所在的目录prefix: classpath:/templates/#check-tempate-location: 检查模板路径是否存在check-template-location: true#cache: 是否缓存开发模式下设置为false避免改了模板还要重启服务器线上设置为true可以提高性能。cache: falsesuffix: .htmlencoding: UTF-8mode: HTML5datasource:url: jdbc:mysql://localhost:3306/spring_bootusername: rootpassword: root123456driver-class-name: com.mysql.jdbc.Driver application-test.yml测试环境 ...application-prd.yml生产环境 ...4.2.4 核心配置 spring:profiles:active: dev # active: test # active: prdserver:# 端口号port: 8081servlet:# 设置spring-boot项目访问路径context-path: /Springboot 默认的情况下整合tomcat容器8080端口。 参考 余胜军
http://www.hkea.cn/news/14317245/

相关文章:

  • 重庆网站建站价格东营 微信网站建设
  • 网站积分程序怎么建设江苏建设招标网站
  • 官网建站合作模版个人做论坛网站要什么证件
  • 经典网站建设案例wordpress外贸模板
  • 青岛建网站人知名室内设计网站
  • 网站建设 秦皇岛公司哪家好电商网页设计教程
  • 做企业网站建设公司哪家好乐潍清网站额建设
  • 网站怎么做下载链接无锡网络推广公司
  • 香河做网站湖南seo推广方法
  • net网站开发 兼职黄骅市属于
  • 本地顺德网站建设找企业名录的网站
  • php网站模板下载财务软件哪个最好用最简单
  • 建立网站 要怎么做做网站的属于什么岗位
  • 潍坊网站建设优化想找个人建网站
  • 做一静态网站 多少钱浙江1万家企业
  • 网站运营面试问题怎么成立自己的网站
  • 大学生可以做的网站网络营销怎么做有特色
  • 网站建设合同示范文本网页微信注册新号怎么注册
  • 江苏外贸网站建设腾讯云服务器用什么软件做网站
  • 红旗渠建设集团网站浙江省建设信息港岗位证书查询
  • 网站 项目 需求成都视觉设计公司
  • 怎么做网站小图标公司不需要做网站了
  • 北京网站设计有名 乐云践新简单做网站的价格
  • 辽宁住房和建设厅网站首页黑龙江省建设工程招标网站
  • 建设银行网站电子支付在哪里net淘宝网站开发的例子
  • 做磨毛布内销哪个网站比较好什么网站做首页
  • 如何建设微网站微信运营专员是什么工作
  • 曼斯特(北京)网站建设公司网页回合制游戏排行榜
  • 怎样做网站后台深圳app定制开发外包公司
  • 温州企业网站建设费用厚街手机网站建设