IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

SpringBoot 笔记 二:搭建自己的第一个SpringBoot程序

IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

声明:本文来源于MLDN培训视频的课堂笔记,写在这里只是为了方便查阅。

一、根据官网手工搭建(http://projects.spring.io/spring-boot/#quick-start)

1、新建一个maven工程springbootfirst

71_1.png

2、 如果要想开发 SpringBoot 程序只需要按照官方给出的要求配置一个父 pom (spring-boot-starter-parent)和添加web开发的支持(spring-boot-starter-web)即可。

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>

   <groupId>com.study.springboot</groupId>
   <artifactId>springbootfirst</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <packaging>jar</packaging>

   <name>springbootfirst</name>
   <url>http://maven.apache.org</url>

   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <jdk.version>1.8</jdk.version>
   </properties>

     <!--想开发 SpringBoot 程序只需要按照官方给出的要求配置一个父 pom 即可。  -->
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
         <version>1.5.4.RELEASE</version>
     </parent>

   <dependencies>

     <!--添加web开发的支持  -->
     <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>
     </dependency>

   </dependencies>


   <build>
         <finalName>springbootfirst</finalName>
         <plugins>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <configuration>
                     <source>${jdk.version}</source><!-- 源代码使用的开发版本 -->
                     <target>${jdk.version}</target><!-- 需要生成的目标class文件的编译版本 -->
                     <encode>${project.build.sourceEncoding}</encode>
                 </configuration>
             </plugin>
         </plugins>
     </build>

 </project>

3、 编写一个具体的程序SampleController.java

 package com.study.springboot.springbootfirst;

 import org.springframework.boot.*;
 import org.springframework.boot.autoconfigure.*;
 import org.springframework.stereotype.*;
 import org.springframework.web.bind.annotation.*;

 @Controller
 @EnableAutoConfiguration
 public class SampleController {

     @RequestMapping("/")
     @ResponseBody
     String home() {
         return "Hello World!";
     }

     public static void main(String[] args) throws Exception {
         SpringApplication.run(SampleController.class, args);
     }
 }

4、启动SampleController.java,在浏览器输入http://localhost:8080/即可看到我们使用SpringBoot搭建的第一个web程序成功了,就是这么的快速、简单、方便

71_2.png

二、快速搭建

1、访问http://start.spring.io/

2、选择构建工具Maven Project、Spring Boot版本1.5.11以及一些工程基本信息,点击“Switch to the full version.”java版本选择1.8,可参考下图所示:

71_3.png

3、点击Generate Project下载项目压缩包

4、解压后,使用eclipse,Import -> Existing Maven Projects -> Next ->选择解压后的文件夹-> Finsh,OK done!

来源:https://www.cnblogs.com/leeSmall/category/1185488.html

文章永久链接:https://tech.souyunku.com/?p=13967

赞(77) 打赏



未经允许不得转载:搜云库技术团队 » SpringBoot 笔记 二:搭建自己的第一个SpringBoot程序

IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码
IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

评论 抢沙发

大前端WP主题 更专业 更方便

联系我们联系我们

觉得文章有用就打赏一下文章作者

微信扫一扫打赏

微信扫一扫打赏


Fatal error: Uncaught Exception: Cache directory not writable. Comet Cache needs this directory please: `/data/wangzhan/tech.souyunku.com.wp/wp-content/cache/comet-cache/cache/https/tech-souyunku-com/index.q`. Set permissions to `755` or higher; `777` might be needed in some cases. in /data/wangzhan/tech.souyunku.com.wp/wp-content/plugins/comet-cache/src/includes/traits/Ac/ObUtils.php:367 Stack trace: #0 [internal function]: WebSharks\CometCache\Classes\AdvancedCache->outputBufferCallbackHandler() #1 /data/wangzhan/tech.souyunku.com.wp/wp-includes/functions.php(5109): ob_end_flush() #2 /data/wangzhan/tech.souyunku.com.wp/wp-includes/class-wp-hook.php(303): wp_ob_end_flush_all() #3 /data/wangzhan/tech.souyunku.com.wp/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters() #4 /data/wangzhan/tech.souyunku.com.wp/wp-includes/plugin.php(470): WP_Hook->do_action() #5 /data/wangzhan/tech.souyunku.com.wp/wp-includes/load.php(1097): do_action() #6 [internal function]: shutdown_action_hook() #7 {main} thrown in /data/wangzhan/tech.souyunku.com.wp/wp-content/plugins/comet-cache/src/includes/traits/Ac/ObUtils.php on line 367