温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

idea中怎么搭建springboot项目

发布时间:2022-04-06 15:38:56 来源:亿速云 阅读:122 作者:iii 栏目:移动开发

这篇文章主要介绍“idea中怎么搭建springboot项目”,在日常操作中,相信很多人在idea中怎么搭建springboot项目问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”idea中怎么搭建springboot项目”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

Spring Boot是由Pivotal团队提供的全新框架,设计目的是用来简化新Spring应用的初始搭建以及开发过程。它主要推崇的是'消灭配置',实现零配置。

那么,如何在idea中创建一个springboot项目呢?

一.在你建立的工程下创建 Module 选择Spring initializr创建。

idea中怎么搭建springboot项目

二.在Type处选择: Maven Project(项目的构建工具)

idea中怎么搭建springboot项目

三.创建依赖时勾上web,mybatis,mysql(这个看你个人需要吧,可以自主选择)

idea中怎么搭建springboot项目

idea中怎么搭建springboot项目

建立好的项目结构如下:

idea中怎么搭建springboot项目

相对应的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 这是我手动引入的 因为我需要连接数据库-->
    <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
#数据库连接池
spring: datasource: username: root password: sasa url: jdbc:mysql://localhost:3306/ssm driver-class-name: com.mysql.jdbc.Driver

启动

idea中怎么搭建springboot项目

到此,关于“idea中怎么搭建springboot项目”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI