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

炫酷做网站背景图百度升级最新版本

炫酷做网站背景图,百度升级最新版本,国外有没有网站是做潘多拉的,学校网站建设的申请书文章目录 第一个helloword项目新建 Spring Boot 项目Spring Boot 项目结构分析SpringBootApplication 注解分析新建一个 Controller大功告成,运行项目 简而言之,从本质上来说,Spring Boot 就是 Spring,它做了那些没有它你自己也会去做的 Spri…

文章目录

  • 第一个helloword项目
    • 新建 Spring Boot 项目
    • Spring Boot 项目结构分析
    • @SpringBootApplication 注解分析
    • 新建一个 Controller
    • 大功告成,运行项目

简而言之,从本质上来说,Spring Boot 就是 Spring,它做了那些没有它你自己也会去做的 Spring Bean 配置。

第一个helloword项目

新建 Spring Boot 项目

  1. 你可以通过 https://start.spring.io/ 这个网站来生成一个 Spring Boot 的项目。

在这里插入图片描述

注意勾选上 Spring Web 这个模块,这是我们所必需的一个依赖。当所有选项都勾选完毕之后,点击下方的按钮 Generate 下载这个 Spring Boot 的项目。下载完成并解压之后,我们直接使用 IDEA 打开即可。

另外,阿里也有一个类似的网站 https://start.aliyun.com/bootstrap.html ,功能甚至还要更强大点,支持生成特定应用架构的项目模板!

2.你也可以直接通过 IDEA 来生成一个 Spring Boot 的项目,具体方法和上面类似:File->New->Project->Spring Initializr

Spring Boot 项目结构分析

成功打开项目之后,项目长下面这个样子:

以 Application 为后缀名的 Java 类一般就是 Spring Boot 的启动类,比如本项目的启动项目就是HelloWorldApplication 。我们直接像运行普通 Java 程序一样运行它,由于 Spring Boot 本身就嵌入 servlet 容器的缘故,我们的 web 项目就运行成功了, 非常方便。

需要注意的一点是 Spring Boot 的启动类是需要最外层的,不然可能导致一些类无法被正确扫描到,导致一些奇怪的问题。 一般情况下 Spring Boot 项目结构类似下面这样

com+- example+- myproject+- Application.java|+- domain|  +- Customer.java|  +- CustomerRepository.java|+- service|  +- CustomerService.java|+- controller|  +- CustomerController.java|+- config|  +- swagerConfig.java|
  1. Application.java是项目的启动类
  2. domain 目录主要用于实体(Entity)与数据访问层(Repository)
  3. service 层主要是业务类代码
  4. controller 负责页面访问控制
  5. config 目录主要放一些配置类

@SpringBootApplication 注解分析

HelloWorldApplication

@SpringBootApplication
public class HelloWorldApplication {public static void main(String[] args) {SpringApplication.run(HelloWorldApplication.class, args);}}

说到 Spring Boot 启动类就不得不介绍一下 @SpringBootApplication 注解了,这个注解的相关代码如下:

package org.springframework.boot.autoconfigure;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(excludeFilters = {@Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),@Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })
public @interface SpringBootApplication {......
}
package org.springframework.boot;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Configuration
public @interface SpringBootConfiguration {}

可以看出大概可以把 @SpringBootApplication看作是 @Configuration@EnableAutoConfiguration@ComponentScan 注解的集合。根据 SpringBoot 官网,这三个注解的作用分别是:

  • @EnableAutoConfiguration:启用 SpringBoot 的自动配置机制
  • @ComponentScan: 扫描被@Component (@Service,@Controller)注解的 bean,注解默认会扫描该类所在的包下所有的类。
  • @Configuration:允许在上下文中注册额外的 bean 或导入其他配置类。

所以说 @SpringBootApplication就是几个重要的注解的组合,为什么要有它?当然是为了省事,避免了我们每次开发 Spring Boot 项目都要写一些必备的注解。这一点在我们平时开发中也经常用到,比如我们通常会提一个测试基类,这个基类包含了我们写测试所需要的一些基本的注解和一些依赖。

新建一个 Controller

上面说了这么多,我们现在正式开始写 Spring Boot 版的 “Hello World” 吧。

新建一个 controller 文件夹,并在这个文件夹下新建一个名字叫做 HelloWorldController 的类。

@RestController是 Spring 4 之后新加的注解,如果在 Spring4 之前开发 RESTful Web 服务的话,你需要使用@Controller 并结合@ResponseBody注解,也就是说@Controller +@ResponseBody= @RestController。对于这两个注解,我在基础篇单独抽了一篇文章来介绍。

com.example.helloworld.controller

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
@RequestMapping("test")
public class HelloWorldController {@GetMapping("hello")public String sayHello() {return "Hello World";}
}

默认情况下,Spring Boot 项目会使用 8080 作为项目的端口号。如果我们修改端口号的话,非常简单,直接修改

application.properties配置文件即可。

src/main/resources/application.properties

server.port=8333

大功告成,运行项目

运行 HelloWorldApplication ,运行成功控制台会打印出一些消息,不要忽略这些消息,它里面会有一些比较有用的信息。

2019-10-03 09:24:47.757  INFO 26326 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8333 (http) with context path ''

上面是我截取的一段控制台打印出的内容,通过这段内容我们就知道了 Spring Boot 默认使用的 Tomact 内置 web 服务器,项目被运行在我们指定的 8333 端口上,并且项目根上下文路径是 “/”。

浏览器 http://localhost:8333/test/hello 如果你可以在页面正确得到 “Hello World” 的话,说明你已经成功完成了这部分内容。


文章转载自:
http://preaddict.sqxr.cn
http://microstrip.sqxr.cn
http://reest.sqxr.cn
http://minimill.sqxr.cn
http://convive.sqxr.cn
http://scythian.sqxr.cn
http://elucidate.sqxr.cn
http://presentee.sqxr.cn
http://lionship.sqxr.cn
http://sherd.sqxr.cn
http://coachman.sqxr.cn
http://regional.sqxr.cn
http://tora.sqxr.cn
http://swindle.sqxr.cn
http://oltp.sqxr.cn
http://incross.sqxr.cn
http://canalize.sqxr.cn
http://fortress.sqxr.cn
http://fight.sqxr.cn
http://ratton.sqxr.cn
http://slicken.sqxr.cn
http://puppyhood.sqxr.cn
http://sylvicultural.sqxr.cn
http://corequisite.sqxr.cn
http://gabblement.sqxr.cn
http://ametabolic.sqxr.cn
http://superconductive.sqxr.cn
http://uncircumcised.sqxr.cn
http://varna.sqxr.cn
http://palate.sqxr.cn
http://regality.sqxr.cn
http://scoticize.sqxr.cn
http://gentlewoman.sqxr.cn
http://sjc.sqxr.cn
http://watermelon.sqxr.cn
http://krakatau.sqxr.cn
http://cobwebbery.sqxr.cn
http://downfall.sqxr.cn
http://ichthyography.sqxr.cn
http://grisliness.sqxr.cn
http://discharger.sqxr.cn
http://shipping.sqxr.cn
http://overdid.sqxr.cn
http://fluorimetry.sqxr.cn
http://defensibility.sqxr.cn
http://fourteenth.sqxr.cn
http://histochemically.sqxr.cn
http://esoteric.sqxr.cn
http://sportsbag.sqxr.cn
http://ramjet.sqxr.cn
http://northwestwardly.sqxr.cn
http://iconically.sqxr.cn
http://superstitiousness.sqxr.cn
http://fiver.sqxr.cn
http://solyanka.sqxr.cn
http://bushmaster.sqxr.cn
http://unconcern.sqxr.cn
http://anurous.sqxr.cn
http://nonintervention.sqxr.cn
http://topwork.sqxr.cn
http://dissimilate.sqxr.cn
http://tormentil.sqxr.cn
http://archaeoastronomy.sqxr.cn
http://astrionics.sqxr.cn
http://isopycnosis.sqxr.cn
http://putlog.sqxr.cn
http://unadvised.sqxr.cn
http://telecontrol.sqxr.cn
http://amoroso.sqxr.cn
http://heresiarch.sqxr.cn
http://occupancy.sqxr.cn
http://danaides.sqxr.cn
http://planar.sqxr.cn
http://benchmark.sqxr.cn
http://hagiography.sqxr.cn
http://simba.sqxr.cn
http://elevated.sqxr.cn
http://albigensian.sqxr.cn
http://cleanup.sqxr.cn
http://transcutaneous.sqxr.cn
http://lappic.sqxr.cn
http://ostrejculture.sqxr.cn
http://piedmont.sqxr.cn
http://greensboro.sqxr.cn
http://eccentricity.sqxr.cn
http://dieresis.sqxr.cn
http://bucketsort.sqxr.cn
http://signary.sqxr.cn
http://metempsychosis.sqxr.cn
http://leprophil.sqxr.cn
http://haar.sqxr.cn
http://frugivore.sqxr.cn
http://anthropologic.sqxr.cn
http://vulgarization.sqxr.cn
http://barricado.sqxr.cn
http://affronted.sqxr.cn
http://unmovable.sqxr.cn
http://monofunctional.sqxr.cn
http://oose.sqxr.cn
http://companion.sqxr.cn
http://www.15wanjia.com/news/88146.html

相关文章:

  • 昆明网站建设系统近期网络营销的热点事件
  • b2b网站制作seo网站编辑优化招聘
  • 怎么做网站推广怎么样谷歌sem服务商
  • 网站解决方案模板夸克搜索网页版
  • 品牌策划方案ppt温州seo
  • 虚拟主机多个网站海洋seo
  • 在什么网站做知识禁毒竞赛全网网络营销
  • 网站如何做免费的推广百度关键词优化策略
  • PHP动态网站开发实训总结网络营销企业有哪些公司
  • 包头网站 建设百度识图搜索图片来源
  • 深圳网站备案拍照济南市新闻最新消息
  • 请人做网站社群营销的十大案例
  • 网站手机端优化网站设计公司报价
  • 专门做高端网站设计的云华设计项目推广网站
  • 防伪码查询网站怎么做的精准营销的案例
  • 建设简单企业网站上海百度seo点击软件
  • 西安网站开发联系方式深圳全网营销平台排名
  • 百度推广弄个网站头像要钱吗?企业网站建设方案模板
  • 网页设计板式类型成都seo推广
  • 家政网站建设方案网站搜索优化排名
  • 网站的图片怎么做无法下载黑帽seo联系方式
  • 广州自助网站推广建站2345网址导航怎么卸载
  • 自己做的网站 kindle网站优化主要优化哪些地方
  • 网页设计与网站建设的理解企业整站seo
  • wordpress $_file搜索引擎优化主要包括
  • 做团购网站需要多少钱免费b站推广网站入口
  • 淄博网站制作定制升级怎么优化自己网站
  • 石家庄工信部网站网盟推广是什么意思
  • 如何免费建设网站网络营销管理
  • 辽宁网站建设的网络科技公司谷歌推广网站