溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

idea中怎么搭建springboot項目

發(fā)布時間:2022-04-06 15:38:56 來源:億速云 閱讀:138 作者:iii 欄目:移動開發(fā)

這篇文章主要介紹“idea中怎么搭建springboot項目”,在日常操作中,相信很多人在idea中怎么搭建springboot項目問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”idea中怎么搭建springboot項目”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!

Spring Boot是由Pivotal團(tuán)隊提供的全新框架,設(shè)計目的是用來簡化新Spring應(yīng)用的初始搭建以及開發(fā)過程。它主要推崇的是'消滅配置',實現(xiàn)零配置。

那么,如何在idea中創(chuàng)建一個springboot項目呢?

一.在你建立的工程下創(chuàng)建 Module 選擇Spring initializr創(chuàng)建。

idea中怎么搭建springboot項目

二.在Type處選擇: Maven Project(項目的構(gòu)建工具)

idea中怎么搭建springboot項目

三.創(chuàng)建依賴時勾上web,mybatis,mysql(這個看你個人需要吧,可以自主選擇)

idea中怎么搭建springboot項目

idea中怎么搭建springboot項目

建立好的項目結(jié)構(gòu)如下:

idea中怎么搭建springboot項目

相對應(yīng)的pom.xml文件

<?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>
  <groupId>com</groupId>
  <artifactId>demo</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>demo</name>
  <description>Demo project for Spring Boot</description>
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.9.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
  </parent>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.mybatis.spring.boot</groupId>
      <artifactId>mybatis-spring-boot-starter</artifactId>
      <version>1.3.1</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
    <!--c3p0 這是我手動引入的 因為我需要連接數(shù)據(jù)庫-->
    <dependency>
      <groupId>com.mchange</groupId>
      <artifactId>c3p0</artifactId>
      <version>0.9.5.2</version>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

</project>

application.yml(項目建城時這個application文件的后綴名不叫yml,是官方推薦把后綴改成yml的,好處是代碼有提示)

mybatis:
 mapper-locations: classpath:mapper/*.xml
 type-aliases-package: com.demo.pojo
#數(shù)據(jù)庫連接池
spring: datasource: username: root password: sasa url: jdbc:mysql://localhost:3306/ssm driver-class-name: com.mysql.jdbc.Driver

啟動

idea中怎么搭建springboot項目

到此,關(guān)于“idea中怎么搭建springboot項目”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注億速云網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI