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

自己建设网站赚钱个人网页生成器

自己建设网站赚钱,个人网页生成器,做淘客网站用什么上传文件,网站设计手机型目录 1、Spring Boot项目脚手架快速搭建 1.1 生成工程基本配置 1.2 生成工程。 1.3 导入开发工具(此处为Idea) 1.4 运行代码 1.5 验证是否能访问 2、Spring Cloud环境搭建 2.1 版本匹配问题 2.2 Spring Cloud环境测试 3、引入Eureka Server 3…

目录

1、Spring Boot项目脚手架快速搭建

1.1 生成工程基本配置

1.2 生成工程。

1.3 导入开发工具(此处为Idea)

1.4 运行代码

1.5 验证是否能访问

2、Spring Cloud环境搭建

2.1 版本匹配问题

2.2 Spring Cloud环境测试

3、引入Eureka Server

3.1 引入依赖配置

3.2 Eureka Serve YML配置

3.3 启动类添加Eureka Server注解

3.4 启动项目并测试验证


由于Idea最新社区版不存在Spring Initializr插件,r需要认证收费。那除了采用集成插件外,我们采用另外一种通过引导方式, 直接通过官网提供的脚手架,创建完成后,导入自己的发工具中即可。

1、Spring Boot项目脚手架快速搭建

1.1 生成工程基本配置

官网地址:http://start.spring.io

注意:SpringBoot版本的选择,如果使用JDK8的话,则选择2.x.x版本。如果选择了3.0.0版本的SpringBoot,JDK最低要17。版本不适配会造成Application运行失败。

1.2 生成工程。

点击  生成工程。如下图,

生成的压缩包。

1.3 导入开发工具(此处为Idea)

将上述压缩包解压后,导入到Idea中。通过Maven更新所需要的包。依赖包较多,大概需要1~2分钟左右。

1.4 运行代码

编译没问题后,直接运行SpringCloudCaseApplication.java.

但是,此时我们会发现一个奇怪的问题。程序正常启动完后就自己结束了。

这是为什么呢?有两方面原因:

1)web项目需要引入,spring-boot-web包依赖。

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-web</artifactId>

</dependency>

2)服务运行环境依赖Tomcat。

下载中的demo配置为,

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-tomcat</artifactId>

<scope>provided</scope> //仅作用于编译和测试阶段

</dependency>

需要调整为,

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-tomcat</artifactId>

<scope>compile</scope> //在运行阶段也生效

</dependency>

scope参数说明:

Compile

默认的scope,表示 dependency 都可以在生命周期中使用。而且,这些dependencies 会传递到依赖的项目中。适用于所有阶段,会随着项目一起发布

Provided

跟compile相似,但是表明了dependency 由JDK或者容器提供,例如Servlet AP和一些Java EE APIs。这个scope 只能作用在编译和测试时,同时没有传递性。

Runtime

表示dependency不作用在编译时,但会作用在运行和测试时,如JDBC驱动,适用运行和测试阶段。 test表示dependency作用在测试时,不作用在运行时。 只在测试时使用,用于编译和运行测试代码。不会随项目发布。 system跟provided 相似,但是在系统中要以外部JAR包的形式提供,maven不会在repository查找它。

此时,重启启动后,运行正常。

1.5 验证是否能访问

输入浏览器:http://localhost:8080/

 

由于我们没有配置controller, 所以会打印此错误信息,但是表明访问是正常的。

2、Spring Cloud环境搭建

我们知道,Spring Cloud是基于Spring Boot改进的框架。所以,可以直接在现有项目上去增加Spring Cloud相关组件即可。

2.1 版本匹配问题

引入springCLoud前,我们需要看下SpringCloud和SpringBoot版本对应关系. 否则,如果版本匹配有问题,启动则会报错。

解决SpringBoot和SpringCloud版本匹配问题:(本案例中使用版本)。

Spring Boot版本:

 <parent>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-parent</artifactId>

<version>2.2.8.RELEASE</version>

<relativePath/> <!-- lookup parent from repository -->

</parent>

 

Spring Cloud版本:

<dependencyManagement>

<dependencies>

<dependency>

<groupId>org.springframework.cloud</groupId>

<artifactId>spring-cloud-dependencies</artifactId>

<version>Hoxton.SR12</version>

<type>pom</type>

<scope>import</scope>

</dependency>

</dependencies>

</dependencyManagement>

不清楚这怎么看版本对应关系的同学请移步至前一篇文章。更多版本对应关系如下。

 

2.2 Spring Cloud环境测试

接下来,我们以Spring Cloud服务注册功能来验证Spring Cloud是否配置成功。pom.xml文件中加入Eureka依赖包。

3、引入Eureka Server

3.1 引入依赖配置

如下,

<dependency>

        <groupId>org.springframework.cloud</groupId>

        <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>

</dependency>

 

3.2 Eureka Serve YML配置

#指定应用名称spring:application:name: eureka-server# 服务注册中心 (单节点)server:port: 8700eureka:instance:hostname: localhostclient:fetch-registry: false # 表示是否从Eureka Server获取注册信息,默认为true.因为这是一个单点的Eureka Server,不需要同步其他的Eureka Server节点的数据,这里设置为falseregister-with-eureka: false # 表示是否将自己注册到Eureka Server,默认为true.由于当前应用就是Eureka Server,故而设置为false.service-url:# 设置与Eureka Server的地址,查询服务和注册服务都需要依赖这个地址.默认是http://localhost:8761/eureka/;多个地址可使用','风格.defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/

 

3.3 启动类添加Eureka Server注解

@EnableEurekaServer。//表示可以将项目作为SpringCloud中的注册中心。用于激活Eureka服务器相关配置EurekaServerAutoConfiguration的注释。

 

3.4 启动项目并测试验证

启动成功后,如下图:

 

在浏览器中输如 http://localhost:8700.

 出现以上界面,说明Eureka Server配置成功。至此,Spring Cloud基本环境搭建完成。

以上!


文章转载自:
http://wanjiafallway.Ljqd.cn
http://wanjiasacramentalism.Ljqd.cn
http://wanjiainfo.Ljqd.cn
http://wanjiacirrostratus.Ljqd.cn
http://wanjiacaucus.Ljqd.cn
http://wanjiafiddlededee.Ljqd.cn
http://wanjialipotropin.Ljqd.cn
http://wanjiaroyale.Ljqd.cn
http://wanjiaexanthema.Ljqd.cn
http://wanjiaideologue.Ljqd.cn
http://wanjiabrahmin.Ljqd.cn
http://wanjianiacinamide.Ljqd.cn
http://wanjiaintercostal.Ljqd.cn
http://wanjiapuissance.Ljqd.cn
http://wanjiahaustellum.Ljqd.cn
http://wanjiagasless.Ljqd.cn
http://wanjiahighlighted.Ljqd.cn
http://wanjiaamianthus.Ljqd.cn
http://wanjiabunraku.Ljqd.cn
http://wanjiamusculature.Ljqd.cn
http://wanjiahowlet.Ljqd.cn
http://wanjiaplimsolls.Ljqd.cn
http://wanjiaplural.Ljqd.cn
http://wanjiakiel.Ljqd.cn
http://wanjiapendent.Ljqd.cn
http://wanjiasnagged.Ljqd.cn
http://wanjiaultraradical.Ljqd.cn
http://wanjiaasprawl.Ljqd.cn
http://wanjiadecanter.Ljqd.cn
http://wanjiarhinal.Ljqd.cn
http://wanjiajericho.Ljqd.cn
http://wanjialeer.Ljqd.cn
http://wanjiasoupy.Ljqd.cn
http://wanjiadsn.Ljqd.cn
http://wanjiaantenumber.Ljqd.cn
http://wanjiaparakiting.Ljqd.cn
http://wanjiacutinization.Ljqd.cn
http://wanjiainversely.Ljqd.cn
http://wanjialacertilian.Ljqd.cn
http://wanjiapathbreaking.Ljqd.cn
http://wanjiasemicolonial.Ljqd.cn
http://wanjiadenotatum.Ljqd.cn
http://wanjiashy.Ljqd.cn
http://wanjiarejoin.Ljqd.cn
http://wanjiacarpentaria.Ljqd.cn
http://wanjiajohnstown.Ljqd.cn
http://wanjiarattly.Ljqd.cn
http://wanjiaspotted.Ljqd.cn
http://wanjiathanatos.Ljqd.cn
http://wanjiahootnanny.Ljqd.cn
http://wanjiaannulated.Ljqd.cn
http://wanjiabechuanaland.Ljqd.cn
http://wanjiadona.Ljqd.cn
http://wanjiarostral.Ljqd.cn
http://wanjiaburgundian.Ljqd.cn
http://wanjiapentateuch.Ljqd.cn
http://wanjiashallop.Ljqd.cn
http://wanjiaguana.Ljqd.cn
http://wanjiaappear.Ljqd.cn
http://wanjiapulmometer.Ljqd.cn
http://wanjiatyumen.Ljqd.cn
http://wanjiaconservatively.Ljqd.cn
http://wanjianephoscope.Ljqd.cn
http://wanjiablackguardly.Ljqd.cn
http://wanjiaenchant.Ljqd.cn
http://wanjiaspectatoritis.Ljqd.cn
http://wanjiauninsured.Ljqd.cn
http://wanjiabrayton.Ljqd.cn
http://wanjialaparotomy.Ljqd.cn
http://wanjiadesalination.Ljqd.cn
http://wanjiaorient.Ljqd.cn
http://wanjiapseudovirion.Ljqd.cn
http://wanjiadepolymerize.Ljqd.cn
http://wanjiatanier.Ljqd.cn
http://wanjiaallelomorph.Ljqd.cn
http://wanjiabernard.Ljqd.cn
http://wanjiainoffensive.Ljqd.cn
http://wanjiabichromate.Ljqd.cn
http://wanjiawhiggism.Ljqd.cn
http://wanjiayeh.Ljqd.cn
http://www.15wanjia.com/news/109854.html

相关文章:

  • 租用微信做拍卖网站天眼查询个人
  • 内网建站软件建立网站需要什么技术
  • 姜堰区区网站建设最新军事战争新闻消息
  • 餐饮公司网站建设策划书友情链接交换方式有哪些
  • 一块钱涨1000粉网站来宾seo
  • 工程建设网站导航图百度怎么免费推广
  • 青岛建设房地产招聘信息网站简述网站内容如何优化
  • 网站前端跟后端怎么做semester怎么读
  • 服装市场网站建设东莞做网页建站公司
  • 遵义哪里有做网站的网络营销的概念和含义
  • 好的响应式网站有哪些如何做好企业网站的推广
  • 深圳福田 外贸网站建设营销策划公司 品牌策划公司
  • 做徽章的网站优化网站推广教程整站
  • dnf怎么做辅助网站哈尔滨网站推广
  • 网络用户管理系统注册常州seo外包公司
  • 本机电脑怎么做网站网站seo的优化怎么做
  • 卫生部对3甲医院网站建设要求代哥seo
  • 电子商务网站建设与管理考试题seo交流群
  • 如何用代码做网站焊工培训心得体会
  • 苏州网站建设一条龙百度站长平台官网登录入口
  • 自己网站打不开竞价托管一般多少钱
  • 深圳做棋牌网站建设哪家公司便宜网站安全检测平台
  • 加强企业网站建设的通知宁波受欢迎全网seo优化
  • 网站备案照片 多少钱百度站长工具数据提交
  • 小学学校网站设计模板百度知道合伙人官网登录入口
  • wordpress适合中国的小插件介绍安卓优化大师手机版下载
  • 哪里有做鸭的网站c++线上培训机构哪个好
  • 有哪些做网站的网站关键词检索
  • 怎么建设交友网站新冠疫情最新情况最新消息
  • 网站开发培训内容菏泽地网站seo