Intellij IDEA graphic tutorial for configuring springboot, intellijspringboot

Source: Internet
Author: User

Intellij IDEA graphic tutorial for configuring springboot, intellijspringboot

Introduction to IntelliJ IDEA

IDEA, short for IntelliJ IDEA, is an integrated environment for java Development. IntelliJ is recognized as one of the best java development tools in the industry, especially in smart code assistants, code automatic prompts, refactoring, J2EE support, various version tools (git, svn, github, etc) the functions of JUnit, CVS integration, code analysis, and innovative GUI Design are extraordinary. IDEA is a product of JetBrains, headquartered in Prague, the capital of the Czech Republic. Developers are mainly well-known programmers in Eastern Europe. Its flagship version also supports HTML, CSS, PHP, MySQL, Python, and so on. The free version only supports a few languages such as Java.

Spring Boot is a new framework provided by the Pivotal team. It is designed to simplify the initial setup and development process of new Spring applications. The framework uses a specific method for configuration, so that developers no longer need to define the configuration of the template. In this way, Boot is committed to becoming a leader in the rapidly developing rapid application development Field.

What are the advantages of using spring boot?

It is simple, fast, and convenient! What do we do when we need to build a spring web project?

1) Configure web. xml and load spring and spring mvc

2) Configure database connections and spring transactions

3) Configure to read the configuration file and enable Annotation

4) configure the log file

The following describes how to configure springboot in intellij IDEA. The procedure is as follows:

1. Create a springboot project:

2. Create the file structure of the project and the jdk version.

3. Select the dependencies required by the project

4. File structure

5. The project uses a more concise application. yml file instead of the application. properties file:
Delete the application. properties file in the original resource folder and create a new application. yml configuration file,
The file content is as follows:

Server: port: 8080 spring: datasource: name: test url: jdbc: mysql: // 127.0.0.1: 3306/depot username: root password: root # Use druid Data Source type: com. alibaba. druid. pool. druidDataSource driver-class-name: com. mysql. jdbc. driver filters: stat maxActive: 20 initialSize: 1 maxWait: 60000 minIdle: 1 Role: 60000 role: 300000 validationQuery: select 'x' testWhileIdle: true testOnBorrow: false testOnReturn: false poolPreparedStatements: true maxOpenPreparedStatements: 20 mybatis: mapper-locations: classpath: mapping /*. xml type-aliases-package: com. winter. model # pagehelper: helperDialect: mysql reasonable: true supportMethodsArguments: true params: count = countSql

6. Use mybatis generator to automatically generate code

The content of the generatorConfig. xml configuration file is as follows:

<? Xml version = "1.0" encoding = "UTF-8"?> <! DOCTYPE generatorConfiguration PUBLIC "-// mybatis.org//DTD MyBatis Generator Configuration 1.0 //" http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd "> <generatorConfiguration> <! -- Database DRIVER: select your local hard disk above the database driver package --> <classPathEntry location = "E: \ 1 Note \ java \ jar file \ mysql-connector-java-5.1.7-bin (1 ). jar "/> <context id =" DB2Tables "targetRuntime =" MyBatis3 "> <commentGenerator> <property name =" suppressDate "value =" true "/> <! -- Whether to remove automatically generated comments true: Yes: false: No --> <property name = "suppressAllComments" value = "true"/> </commentGenerator> <! -- Database link URL, user name, password --> <jdbcConnection driverClass = "com. mysql. jdbc. driver "connectionURL =" jdbc: mysql: // 127.0.0.1/mytest "userId =" root "password =" 123456 "> </jdbcConnection> <javaTypeResolver> <property name =" forceBigDecimals "value =" false "/> </ javaTypeResolver> <! -- Generate the model package name and location --> <javaModelGenerator targetPackage = "com. chen. model "targetProject =" src/main/java "> <property name =" enableSubPackages "value =" true "/> <property name =" trimStrings "value =" true "/> </javaModelGenerator> <! -- Generate the package name and location of the ing file --> <sqlMapGenerator targetPackage = "mapping" targetProject = "src/main/resources"> <property name = "enableSubPackages" value = "true "/> </sqlMapGenerator> <! -- Generate the DAO package name and location --> <javaClientGenerator type = "XMLMAPPER" targetPackage = "com. chen. mapper "targetProject =" src/main/java "> <property name =" enableSubPackages "value =" true "/> </javaClientGenerator> <! -- TableName is the table name or view name in the database. domainObjectName is the object class name. --> <table tableName = "t_user" domainObjectName = "User" enableCountByExample = "false" enableUpdateByExample = "false" enableDeleteByExample = "false" enableSelectByExample = "false" selectByExampleQueryId = "false"> </table> </context> </generatorConfiguration>

Click

Spring boot project implements hot deployment in IntelliJ IDEA

Spring-boot-devtools is a module for developers. The most important function is to automatically change the application code to the latest App.

The principle is to restart the application after the code is changed, but the speed is faster than that after the manual stop.

The underlying principle is to use two ClassLoader, one Classloader to load classes that will not change (third-party Jar packages), and the other ClassLoader to load the classes that will change, called restart ClassLoader

In this way, when the code is changed, the original restart ClassLoader is discarded and a restart ClassLoader is re-created. because the number of classes to be loaded is relatively small, the restart time is faster.

That is, devtools listens to file changes under classpath and immediately restarts the application (at the time of storage)

1. Enable idea auto make Function

1. CTRL + SHIFT + A --> Find make project automatically --> select

2. CTRL + SHIFT + A --> Search for Registry --> Find and check compiler. automake. allow. when. app. running.

Restart idea

I. Use the hot deployment feature starting with spring-boot-1.3

1. Add maven dependency

<dependency>  <groupId>org.springframework.boot</groupId>  <artifactId>spring-boot-devtools</artifactId><optional>true</optional></dependency>

2. Enable hot deployment

<Build> <plugins> <plugin> <groupId> org. springframework. boot </groupId> <artifactId> spring-boot-maven-plugin </artifactId> <configuration> <fork> true </fork> // This configuration is required </configuration> </plugin> </plugins> </build>

Summary

The above is a graphic tutorial on configuring springboot for intellij IDEA. I hope it will be helpful to you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.