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

监控网站模版免费seo排名网站

监控网站模版,免费seo排名网站,东莞产品网站建设公司,网站seo查询工具服务端程序本质上也只是个Java程序#xff0c;它接收客户端的输入#xff0c;然后将计算处理后的返回值返回给客户端。下面我们就以这个思路开始Java后端之旅吧。 引用Spring Boot库 处理HTTP请求之类的事情#xff0c;我们需要库的帮助。所以第一步我们就把Spring Boot引…服务端程序本质上也只是个Java程序它接收客户端的输入然后将计算处理后的返回值返回给客户端。下面我们就以这个思路开始Java后端之旅吧。 引用Spring Boot库 处理HTTP请求之类的事情我们需要库的帮助。所以第一步我们就把Spring Boot引入进来。 不需要任何工具我们使用maven来管理库依赖这样我们只要写一个pom.xml就好了。我们先写一个最简的pom.xml。主要是定义groupId比如是我司还有artifactId就是应用的具体名字 ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersiongroupIdcn.alios.system.service.prefix/groupIdartifactIdPrefix/artifactIdversion1.0.0-SNAPSHOT/version/project 添加父引用 类似于类的继承我们不是从头开发而是继承Spring Boot Starter框架。添加parent的内容如下 parentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion2.1.2.RELEASE/version/parent 2.1.2是本文写作时Spring Boot的最新版本。 增加依赖 为了自动下载库我们将需要的几个库添加到pom.xml中的依赖项中。这样maven就可以帮我们从仓库中下载最新的库代码。 我们需要AOP和Web两个包用全名是spring-boot-starter-aop和spring-boot-starter-web: dependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-aop/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependency/dependencies 引用插件 Spring Boot还提供了插件我们也将其引用进来 buildpluginsplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactId/plugin/plugins/build 主函数 库引用完了我们就写一个主程序吧。按照惯例我们将其保存在src/main/java目录下 package cn.alios.system.service.prefix;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody;SpringBootApplication RequestMapping(/) public class Prefix {RequestMapping(/)ResponseBodypublic String home(){return Hello, Java Web World!;}public static void main(String[] args) throws Exception{SpringApplication.run(Prefix.class,args);} } 编译 下面我们用mvn package命令来编译生成可运行的jar包 mvn package 输出类似于下面这样 [INFO] Scanning for projects... [INFO] [INFO] --------------- cn.alios.system.service.prefix:Prefix ---------------- [INFO] Building Prefix 1.0.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) Prefix --- [INFO] Using UTF-8 encoding to copy filtered resources. [INFO] Copying 0 resource [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) Prefix --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to /Users/ziyingliuziying/working/gitlab/Prefix/target/classes [INFO] [INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) Prefix --- [INFO] Using UTF-8 encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /Users/ziyingliuziying/working/gitlab/Prefix/src/test/resources [INFO] [INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) Prefix --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.22.1:test (default-test) Prefix --- [INFO] No tests to run. [INFO] [INFO] --- maven-jar-plugin:3.1.1:jar (default-jar) Prefix --- [INFO] Building jar: /Users/ziyingliuziying/working/gitlab/Prefix/target/Prefix-1.0.0-SNAPSHOT.jar [INFO] [INFO] --- spring-boot-maven-plugin:2.1.2.RELEASE:repackage (repackage) Prefix --- [INFO] Replacing main artifact with repackaged archive [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.462 s [INFO] Finished at: 2019-01-31T16:53:4808:00 [INFO] ------------------------------------------------------------------------ 最后生成的包是target/Prefix-1.0.0-SNAPSHOT.jar。 运行 调用java -jar target/Prefix-1.0.0-SNAPSHOT.jar命令运行这个Java程序输出如下 . ____ _ __ _ _/\\ / ____ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | _ | _| | _ \/ _ | \ \ \ \\\/ ___)| |_)| | | | | || (_| | ) ) ) ) |____| .__|_| |_|_| |_\__, | / / / /|_||___//_/_/_/:: Spring Boot :: (v2.1.2.RELEASE)2019-01-31 16:59:43.144 INFO 95879 --- [ main] cn.alios.system.service.prefix.Prefix : Starting Prefix v1.0.0-SNAPSHOT on ziyingliuziyingdeMacBook-Pro.local with PID 95879 (/Users/ziyingliuziying/working/gitlab/Prefix/target/Prefix-1.0.0-SNAPSHOT.jar started by ziyingliuziying in /Users/ziyingliuziying/working/gitlab/Prefix) 2019-01-31 16:59:43.148 INFO 95879 --- [ main] cn.alios.system.service.prefix.Prefix : No active profile set, falling back to default profiles: default 2019-01-31 16:59:44.289 INFO 95879 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2019-01-31 16:59:44.325 INFO 95879 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2019-01-31 16:59:44.325 INFO 95879 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.14] 2019-01-31 16:59:44.347 INFO 95879 --- [ main] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/ziyingliuziying/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.] 2019-01-31 16:59:44.435 INFO 95879 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2019-01-31 16:59:44.435 INFO 95879 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1234 ms 2019-01-31 16:59:44.665 INFO 95879 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService applicationTaskExecutor 2019-01-31 16:59:44.886 INFO 95879 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path 2019-01-31 16:59:44.889 INFO 95879 --- [ main] cn.alios.system.service.prefix.Prefix : Started Prefix in 2.161 seconds (JVM running for 2.561) 我们可以看到启动了一个9.0.14版本的Apache Tomcat服务器在8080端口上监听。 我们打开浏览器访问http://127.0.0.1:8080/可以看到『Hello, Java Web World!』这个字符串被显示出来。 再写一个Controller 在主函数里面可以处理请求那么再其它类里面该如何做呢我们通过写Controller注解加上RequestMapping来指定路径就可以了。 我们来写个例子 package cn.alios.system.service.prefix.controller;import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody;Controller RequestMapping(/test) public class TestController {RequestMapping(/)ResponseBodypublic String test(){return Test Controller!;} } 还是mvn package然后java -jar java -jar target/Prefix-1.0.0-SNAPSHOT.jar。 在浏览器里试下http://127.0.0.1:8080/test/显示『Test Controller!』 大功告成现在整个从接收输入到显示输出的通道已经打通是不是很easy? 原文链接 本文为云栖社区原创内容未经允许不得转载。
http://www.huolong8.cn/news/207276/

相关文章:

  • 网站大专ml免费域名注册
  • 网站开发与管理论文济南新网站建设
  • 网站制作是不是要先用ps做长春网站建设网
  • 外贸自建站平台价格扬州seo
  • 国外专业做汽配的网站seo优化关键词分类
  • 建站前期准备怎么在网站做推广不要钱
  • 郑州制作网页的公司seo网站优化软件价格
  • 滨州医学院做计算机作业的网站网站漂浮广告
  • 学习建设网站开发app的网站建设公司
  • 南山商城网站建设找哪家公司比较安全海陵区建设局网站
  • 大同建设局网站网站建设与管理视频教程
  • 大淘客怎样做网站wordpress建站行吗
  • 网站宣传片的创意网页设计基础教程题库
  • 网络推广营销网站建设专家网站收录慢
  • 国家信息企业公示网查询官网seo品牌优化百度资源网站推广关键词排名
  • 当地建设局网站广东专业做网站排名公司
  • 网站建设项目的生命周期wordpress喜欢 赏 分享
  • 免费的网站模板有哪些wordpress pdf下载链接
  • 免费网站建设支持ftpwordpress chess
  • 网站改版要改哪些页面凡科网做网站的图片
  • 深圳网站论坛建设七零三八零四温州论坛
  • 网站建设与管理案例教程ppt3a汽车集团公司网络营销方案
  • 手机版传奇发布网站广州专业网站改版领军企业
  • 始兴县建设局网站怎么做企业官方网站
  • 网站设计思路怎么写图片生成二维码在线制作
  • 外贸球衣网站如何制作自己的网站 可放广告
  • 企业网站建设中有哪几个重要点儿童教育 php模板 网站
  • 溧阳建设集团有限公司网站网站怎么做预约小程序
  • 商城网站建设要多少钱微信小程序怎么做
  • 工信和信息化网站备案系统龙发装饰