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.
2. Select at Type: Maven Project (project build tool)
3. When creating dependencies, check web, mybatis, mysql (this depends on your personal needs, you can choose independently)
The established project structure is as follows:
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>
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
Start
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!