搭建springboot項目

来源:https://www.cnblogs.com/wangjiec/archive/2018/09/28/9717441.html
-Advertisement-
Play Games

1.搭建環境windows10+jdk1.8+eclipse4.8+maven 2.為了學習微服務架構學習搭建基礎項目 3.分為兩種搭建方式為maven項目和單獨建立springboot項目(eclipse需要安裝相關的插件) 第一種使用maven搭建 1)創建maven項目 file--new o ...


1.搭建環境windows10+jdk1.8+eclipse4.8+maven

2.為了學習微服務架構學習搭建基礎項目

3.分為兩種搭建方式為maven項目和單獨建立springboot項目(eclipse需要安裝相關的插件)

第一種使用maven搭建

1)創建maven項目  file--new---other --maven-project

2) 配置pom文件將springbootz相關的包引入

<?xml version="1.0" encoding="UTF-8"?>

<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>
<!-- spring boot基本環境 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
</parent>

<groupId>com.wj</groupId>
<artifactId>springboot</artifactId>
<version>0.0.1-SNAPSHOT</version>

<name>springboot</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!--web應用基本環境配置 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>


</dependencies>

<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- spring-boot-maven-plugin插件就是打包spring boot應用的 -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

</plugins>
</pluginManagement>
</build>
</project>

3)創建先關的資源文件包 src/main/java  和src/main/resources

4)  創建測試的類

      新建目錄com.springboot和com.spring.web兩個目錄

      在com.wj.spring目錄下新建類App.java

      

package com.wj.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
* Hello world!
*
*/
@SpringBootApplication
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}

 

在com.wj.spring.web下新建類OneController.java

package com.wj.springboot.web;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class OneController {

@RequestMapping("/")
@ResponseBody
public String index() {
return "hello spring boot";
}
}

5)然後run運行App.java啟動項目,看日誌輸出視窗出現下圖

  

 

6)在瀏覽器打開路徑http://localhost:8080出現下邊的圖例

即搭建成功

第二種通過新建springboot項目創建

1)eclipse安裝springboot相關插件

     首先查看eclispe的版本

     

 

然後安裝springboot相關插件spring-tool-suite

Eclipse --> Help--> Install new Sofware

2)創建項目

      

3)run運行springbootsApplication.java

4)瀏覽器 訪問http://localhost:8080

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • <!DOCTYPE html><html> <head> <meta charset="utf-8"> <title>紅心</title> <style type="text/css"> body{ margin: 0; overflow: hidden; background: #303035; ...
  • 很抱歉,網站搬新家啦! 網站搬新家啦,即將跳轉新網址~ The website is moving to a new home. It is about to jump to the new website. 若網頁未能自動跳轉新網址,請點擊下麵按鈕進行跳轉! 進入新網址 網站搬新家啦,即將跳轉新網 ...
  • <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>刮刮卡</title> <style> *{ margin: 0; padding: 0; } img{ width: 400px; height: 300px; ...
  • Vue項目開發過程中,會因為很多不同的實際運用需求不斷地對webpack配置進行修改,在此之前,我們需要對webpack有一個基本的認識,瞭解它到底能為我們做些什麼 webpack是一個模塊打包的工具,它的作用是把互相依賴的模塊處理成靜態資源,如下圖所示。. webpack的作用: ● 把依賴樹按需 ...
  • 如果兩次Get請求的URL完全一樣,則IE瀏覽器會調用上次緩存的結果,不會發起新的Http請求。 解決辦法:在URL最後面加上時間戳。 jQuery全局設置禁止緩存 發送請求 運行效果 ...
  • JavaScript for 迴圈 迴圈可以將代碼塊執行指定的次數。 JavaScript 支持不同類型的迴圈: for - 迴圈代碼塊一定的次數 for/in - 迴圈遍歷對象的屬性 while - 當指定的條件為true,迴圈指定的代碼塊 do/while - 當指定的條件為true,迴圈指定的 ...
  • 列表推導式 你有一個list: bag = [1, 2, 3, 4, 5] 現在你想讓所有元素翻倍,讓它看起來是這個樣子: [2, 4, 6, 8, 10] 大多初學者,根據之前語言的經驗會大概這樣來做 bag = [1, 2, 3, 4, 5] for i in range(len(bag)): ...
  • 官網 http://www.fhadmin.org/D 集成安全許可權框架shiro Shiro 是一個用 Java 語言實現的框架,通過一個簡單易用的 API 提供身份驗證和授權,更安全,更可靠E 集成ehcache分散式緩存 是一個純Java的進程內緩存框架,具有快速、精幹等特點,廣泛使用的開源J ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...