Home > Java > javaTutorial > body text

How to build springboot project in idea

PHPz
Release: 2023-05-15 20:28:10
forward
5337 people have browsed it

Spring Boot is a new framework provided by the Pivotal team. It is designed to simplify the initial construction and development process of new Spring applications. What it mainly advocates is 'eliminating configuration' and achieving zero configuration.

So, how to create a springboot project in idea?

1. Create Module under the project you created and select Spring initializr to create it.

How to build springboot project in idea

2. Select at Type: Maven Project (project build tool)

How to build springboot project in idea

3. When creating dependencies, check web, mybatis, mysql (this depends on your personal needs, you can choose independently)

How to build springboot project in idea

How to build springboot project in idea

The established project structure is as follows:

How to build springboot project in idea

The corresponding pom.xml file

<?xml  version="1.0" encoding="UTF-8"?>
<project>
  <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></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>
Copy after login

application.yml (the suffix of this application file was not called yml when the project was built. It is officially recommended to change the suffix to yml. The advantage is that the code has prompts)

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
Copy after login

Start

How to build springboot project in idea

The above is the detailed content of How to build springboot project in idea. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template