亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

IntelliJ?IDEA社區(qū)版2021.3配置SpringBoot項(xiàng)目詳細(xì)教程及失敗案例

 更新時(shí)間:2024年03月21日 10:23:51   作者:是煙花哈  
IntelliJ?IDEA?2021.3.3是一款集成開發(fā)環(huán)境,用于Java和其他編程語言的開發(fā),下面這篇文章主要給大家介紹了關(guān)于IntelliJ?IDEA社區(qū)版2021.3配置SpringBoot項(xiàng)目詳細(xì)教程及失敗案例的相關(guān)資料,需要的朋友可以參考下

一、SpringBoot的定義

Spring 的誕?是為了簡化 Java 程序的開發(fā)的,? Spring Boot 的誕?是為了簡化 Spring 程序開發(fā)的。

Spring Boot 翻譯?下就是 Spring 腳?架,就是為了快速開發(fā) Spring 框架?誕?的

Spring Boot 項(xiàng)?的?大特點(diǎn):約定?于配置。較于Spring需要配置Bean的掃描路徑,而SpringBoot就不需要

二、Spring Boot 優(yōu)點(diǎn)

  • 快速集成框架,Spring Boot 提供了啟動(dòng)添加依賴的功能,?于秒級(jí)集成各種框架。
  • 內(nèi)置運(yùn)?容器,?需配置 Tomcat 等 Web 容器,直接運(yùn)?和部署程序。
  • 快速部署項(xiàng)?,?需外部容器即可啟動(dòng)并運(yùn)?項(xiàng)?。
  • 可以完全拋棄繁瑣的 XML,使?注解和配置的?式進(jìn)?開發(fā)。
  • ?持更多的監(jiān)控的指標(biāo),可以更好的了解項(xiàng)?的運(yùn)?情況。

SpringBoot的核心:

1、快速添加依賴

2、內(nèi)置web容器

3、自動(dòng)裝配(即SpringBoot自動(dòng)構(gòu)建復(fù)雜對(duì)象,構(gòu)建好的對(duì)象可以直接使用)

三、創(chuàng)建一個(gè)springboot的項(xiàng)目

因?yàn)槲覀?的 Idea 社區(qū)版2021.3,選擇安裝SpringBoot插件才能創(chuàng)建 Spring Boot 項(xiàng)目。

SpringBoot插件名字為

 接下來開始正式創(chuàng)建SpringBoot項(xiàng)目:

1、先選擇file->new->project

2、選擇Spring Initializr,選擇國外的默認(rèn)配置源

3、添加項(xiàng)目的依賴

一般是Web項(xiàng)目,所以我們勾選最基本的 Web選項(xiàng),選擇SpringBoot Devtools用于實(shí)現(xiàn)熱部署,其他可以等用到的時(shí)候再添加。

  • Spring Boot Devtools:實(shí)現(xiàn)熱部署
  • Lombok:Java注解
  • Spring Web: 外部服務(wù)

SpringBoot版本選擇后綴不帶英文字母的穩(wěn)定版本,其中低版本的比較穩(wěn)定

點(diǎn)擊下一步,命名自己項(xiàng)目的名字和保存地址,點(diǎn)擊finash,等待項(xiàng)目的創(chuàng)建

開始進(jìn)行啟動(dòng)類初始化:右擊 項(xiàng)目名,選擇“ Add Framework Support

如果出現(xiàn)以下藍(lán)色且右上角帶有三角形則啟動(dòng)類初始化成功

點(diǎn)擊運(yùn)行啟動(dòng)類,出現(xiàn)以下圖形則說明一個(gè)SpringBoot項(xiàng)目已經(jīng)構(gòu)建完成

四、使用IDEA創(chuàng)建SpringBoot失敗案例

由于SpringBoot版本可能與IDEA某些版本產(chǎn)生沖突導(dǎo)致無法創(chuàng)建成功,失敗的案例有如下幾種:

1、Maven缺少plugins和dependencies兩個(gè)選項(xiàng)

2、Cannot resolve symbol 'springframework' 錯(cuò)誤異常

解決方法:

(1)第一種方法:刪除Maven本地的配置文件,重新配置國內(nèi)阿里源在進(jìn)行重新下載Maven進(jìn)行加載

阿里源文件settings.xml如下:

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

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<!--
 | This is the configuration file for Maven. It can be specified at two levels:
 |
 |  1. User Level. This settings.xml file provides configuration for a single user,
 |                 and is normally provided in ${user.home}/.m2/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -s /path/to/user/settings.xml
 |
 |  2. Global Level. This settings.xml file provides configuration for all Maven
 |                 users on a machine (assuming they're all using the same Maven
 |                 installation). It's normally provided in
 |                 ${maven.conf}/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -gs /path/to/global/settings.xml
 |
 | The sections in this sample file are intended to give you a running start at
 | getting the most out of your Maven installation. Where appropriate, the default
 | values (values used when the setting is not specified) are provided.
 |
 |-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->

  <!-- interactiveMode
   | This will determine whether maven prompts you when it needs input. If set to false,
   | maven will use a sensible default value, perhaps based on some other setting, for
   | the parameter in question.
   |
   | Default: true
  <interactiveMode>true</interactiveMode>
  -->

  <!-- offline
   | Determines whether maven should attempt to connect to the network when executing a build.
   | This will have an effect on artifact downloads, artifact deployment, and others.
   |
   | Default: false
  <offline>false</offline>
  -->

  <!-- pluginGroups
   | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
   | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
   | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
   |-->
  <pluginGroups>
    <!-- pluginGroup
     | Specifies a further group identifier to use for plugin lookup.
    <pluginGroup>com.your.plugins</pluginGroup>
    -->
  </pluginGroups>

  <!-- proxies
   | This is a list of proxies which can be used on this machine to connect to the network.
   | Unless otherwise specified (by system property or command-line switch), the first proxy
   | specification in this list marked as active will be used.
   |-->
  <proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     |
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
    -->
  </proxies>

  <!-- servers
   | This is a list of authentication profiles, keyed by the server-id used within the system.
   | Authentication profiles can be used whenever maven must make a connection to a remote server.
   |-->
  <servers>
    <!-- server
     | Specifies the authentication information to use when connecting to a particular server, identified by
     | a unique name within the system (referred to by the 'id' attribute below).
     |
     | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
     |       used together.
     |
    <server>
      <id>deploymentRepo</id>
      <username>repouser</username>
      <password>repopwd</password>
    </server>
    -->

    <!-- Another sample, using keys to authenticate.
    <server>
      <id>siteServer</id>
      <privateKey>/path/to/private/key</privateKey>
      <passphrase>optional; leave empty if not used.</passphrase>
    </server>
    -->
  </servers>

  <!-- mirrors
   | This is a list of mirrors to be used in downloading artifacts from remote repositories.
   |
   | It works like this: a POM may declare a repository to use in resolving certain artifacts.
   | However, this repository may have problems with heavy traffic at times, so people have mirrored
   | it to several places.
   |
   | That repository definition will have a unique id, so we can create a mirror reference for that
   | repository, to be used as an alternate download site. The mirror site will be the preferred
   | server for that repository.
   |-->
  <mirrors>
   <mirror>
        <id>alimaven</id>
        <name>aliyun maven</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        <mirrorOf>central</mirrorOf>        
      </mirror>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
  </mirrors>

  <!-- profiles
   | This is a list of profiles which can be activated in a variety of ways, and which can modify
   | the build process. Profiles provided in the settings.xml are intended to provide local machine-
   | specific paths and repository locations which allow the build to work in the local environment.
   |
   | For example, if you have an integration testing plugin - like cactus - that needs to know where
   | your Tomcat instance is installed, you can provide a variable here such that the variable is
   | dereferenced during the build process to configure the cactus plugin.
   |
   | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
   | section of this document (settings.xml) - will be discussed later. Another way essentially
   | relies on the detection of a system property, either matching a particular value for the property,
   | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
   | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
   | Finally, the list of active profiles can be specified directly from the command line.
   |
   | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
   |       repositories, plugin repositories, and free-form properties to be used as configuration
   |       variables for plugins in the POM.
   |
   |-->
  <profiles>
    <!-- profile
     | Specifies a set of introductions to the build process, to be activated using one or more of the
     | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
     | or the command line, profiles have to have an ID that is unique.
     |
     | An encouraged best practice for profile identification is to use a consistent naming convention
     | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
     | This will make it more intuitive to understand what the set of introduced profiles is attempting
     | to accomplish, particularly when you only have a list of profile id's for debug.
     |
     | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
    <profile>
      <id>jdk-1.4</id>

      <activation>
        <jdk>1.4</jdk>
      </activation>

      <repositories>
        <repository>
          <id>jdk14</id>
          <name>Repository for JDK 1.4 builds</name>
          <url>http://www.myhost.com/maven/jdk14</url>
          <layout>default</layout>
          <snapshotPolicy>always</snapshotPolicy>
        </repository>
      </repositories>
    </profile>
    -->

    <!--
     | Here is another profile, activated by the system property 'target-env' with a value of 'dev',
     | which provides a specific path to the Tomcat instance. To use this, your plugin configuration
     | might hypothetically look like:
     |
     | ...
     | <plugin>
     |   <groupId>org.myco.myplugins</groupId>
     |   <artifactId>myplugin</artifactId>
     |
     |   <configuration>
     |     <tomcatLocation>${tomcatPath}</tomcatLocation>
     |   </configuration>
     | </plugin>
     | ...
     |
     | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
     |       anything, you could just leave off the <value/> inside the activation-property.
     |
    <profile>
      <id>env-dev</id>

      <activation>
        <property>
          <name>target-env</name>
          <value>dev</value>
        </property>
      </activation>

      <properties>
        <tomcatPath>/path/to/tomcat/instance</tomcatPath>
      </properties>
    </profile>
    -->
  </profiles>

  <!-- activeProfiles
   | List of profiles that are active for all builds.
   |
  <activeProfiles>
    <activeProfile>alwaysActiveProfile</activeProfile>
    <activeProfile>anotherAlwaysActiveProfile</activeProfile>
  </activeProfiles>
  -->
</settings>

(2)第二種方法:創(chuàng)建一個(gè)空項(xiàng)目,然后以新建模塊的方式 創(chuàng)建新的SpringBoot項(xiàng)目

 以這種方式,沒有感覺idea 版本和 maven版本存在沖突問題

接下來的步驟就和正常創(chuàng)建SpringBoot的步驟一模一樣了,完成以上全部步驟之后點(diǎn)擊啟動(dòng)類運(yùn)行,如果能運(yùn)行成功則SpringBoot項(xiàng)目就創(chuàng)建成功了。

異常案例:若創(chuàng)建Maven時(shí),pom.xml文件為灰色,沒有變成藍(lán)色時(shí),此時(shí)右鍵點(diǎn)擊pom.xml文件,再點(diǎn)擊 add as maven project  稍等一會(huì)兒導(dǎo)入依賴就可以

說明

之所以沒有配置Tomcat,是因?yàn)镾pring Boot內(nèi)置了Tomcat

主要的幾個(gè)代碼介紹

1、@SpringBootApplication:Spring Boot項(xiàng)目的核心注解,主要目的是開啟自動(dòng)配置。;

2、@Configuration:這是一個(gè)配置Spring的配置類;

3、@Controller:標(biāo)明這是一個(gè)Spring MVC的Controller控制器;

4、main方法:在main方法中啟動(dòng)一個(gè)應(yīng)用,即:這個(gè)應(yīng)用的入口;

總結(jié)

到此這篇關(guān)于IntelliJ IDEA社區(qū)版2021.3配置SpringBoot項(xiàng)目詳細(xì)教程及失敗案例的文章就介紹到這了,更多相關(guān)IDEA社區(qū)版配置SpringBoot項(xiàng)目內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • java詞法分析器DDL遞歸應(yīng)用詳解

    java詞法分析器DDL遞歸應(yīng)用詳解

    這篇文章主要介紹了java詞法分析器DDL遞歸應(yīng)用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-07-07
  • Java ServletContext對(duì)象用法解析

    Java ServletContext對(duì)象用法解析

    這篇文章主要介紹了Java ServletContext對(duì)象用法解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-05-05
  • Springboot分模塊項(xiàng)目搭建的實(shí)現(xiàn)

    Springboot分模塊項(xiàng)目搭建的實(shí)現(xiàn)

    在軟件開發(fā)中,利用Spring?Boot進(jìn)行分模塊項(xiàng)目搭建能夠提高代碼的模塊化和復(fù)用性,本文主要介紹了Springboot分模塊項(xiàng)目搭建的實(shí)現(xiàn),感興趣的可以了解一下
    2024-10-10
  • java 通過聚合查詢實(shí)現(xiàn)elasticsearch的group by后的數(shù)量

    java 通過聚合查詢實(shí)現(xiàn)elasticsearch的group by后的數(shù)量

    這篇文章主要介紹了java 通過聚合查詢實(shí)現(xiàn)elasticsearch的group by后的數(shù)量,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-12-12
  • SpringBoot如何進(jìn)行對(duì)象復(fù)制的實(shí)踐

    SpringBoot如何進(jìn)行對(duì)象復(fù)制的實(shí)踐

    本文主要介紹了SpringBoot 如何進(jìn)行對(duì)象復(fù)制,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • Spring Boot 搭建 ELK正確看日志的配置流程

    Spring Boot 搭建 ELK正確看日志的配置流程

    這篇文章主要介紹了Spring Boot 搭建 ELK正確看日志的配置流程,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-03-03
  • 淺談 JDBC 元數(shù)據(jù)

    淺談 JDBC 元數(shù)據(jù)

    這篇文章主要介紹了JDBC元數(shù)據(jù)的相關(guān)內(nèi)容,涉及一些獲取數(shù)據(jù)源各種信息的方法,具有一定參考價(jià)值,需要的朋友可以了解下。
    2017-09-09
  • 解決Spring Security 用戶帳號(hào)已被鎖定問題

    解決Spring Security 用戶帳號(hào)已被鎖定問題

    這篇文章主要介紹了解決Spring Security 用戶帳號(hào)已被鎖定問題,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-01-01
  • 使用synchronized關(guān)鍵字實(shí)現(xiàn)信號(hào)量的方法

    使用synchronized關(guān)鍵字實(shí)現(xiàn)信號(hào)量的方法

    在Java中,信號(hào)量(Semaphore)是一種常用的同步工具,它可以用來控制對(duì)共享資源的訪問數(shù)量,下面,我們將使用Synchronized關(guān)鍵字來實(shí)現(xiàn)一個(gè)簡單的信號(hào)量,我們的目標(biāo)是實(shí)現(xiàn)一個(gè)計(jì)數(shù)信號(hào)量,其中信號(hào)量的計(jì)數(shù)指示可以同時(shí)訪問某一資源的線程數(shù),需要的朋友可以參考下
    2024-04-04
  • 淺談java多態(tài)的實(shí)現(xiàn)主要體現(xiàn)在哪些方面

    淺談java多態(tài)的實(shí)現(xiàn)主要體現(xiàn)在哪些方面

    下面小編就為大家?guī)硪黄獪\談java多態(tài)的實(shí)現(xiàn)主要體現(xiàn)在哪些方面。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2016-09-09

最新評(píng)論