Introduction to IntelliJ IDEA
IDEA is the full name IntelliJ IDEA. It is an integrated environment for Java language development. IntelliJ is recognized as one of the best Java development tools in the industry. Its functions can be said to be extraordinary in terms of intelligent code assistants, automatic code prompts, reconstruction, J2EE support, various version tools (git, svn, github, etc.), JUnit, CVS integration, code analysis, innovative GUI design, etc. IDEA is a product of JetBrains, the company headquartered in Prague, the capital of the Czech Republic, and mainly developers are known for their rigorous Eastern European programmers. Its flagship version also supports HTML, CSS, PHP, MySQL, Python, etc. 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 construction and development process of new Spring applications. The framework uses a specific way to configure it, so that developers no longer need to define boilerplate configurations. In this way, Boot is committed to becoming a leader in the booming rapid application development.
What are the benefits of using spring boot
In fact, it is simple, fast and convenient! What do we need to do if we need to build a spring web project?
1) Configure web.xml, load spring and spring mvc
2) Configure database connections and spring transactions
3) Configure the reading of load configuration files and enable annotations
4) Configure log files
Here are the steps for configuring springboot in Intellij IDEA. The specific process is as follows:
1. Create a springboot project:
2. Create the file structure of the project and the version of jdk
3. Select the dependencies required for the project
4. File structure
5. The project does not use the application.properties file but uses a more concise application.yml file:
Delete the application.properties file in the original resource folder and create a new application.yml configuration file.
The contents of the file are as follows:
server: port: 8080spring: 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 timeBetweenEvictionRunsMillis: 60000 minEvictableIdleTimeMillis: 300000 validationQuery: select 'x' testWhileIdle: true testOnBorrow: false testOnReturn: false poolPreparedStatements: true maxOpenPreparedStatements: 20mybatis: mapper-locations: classpath:mapping/*.xml type-aliases-package: com.winter.model#pagehelper pagination plugin pagehelper: helperDialect: mysql reasonable: true supportMethodsArguments: true params: count=countSql
6. Use mybatis generator to automatically generate code
GeneratorConfig.xml configuration file content is as follows:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"><generatorConfiguration> <!-- Database Driver: Select the database driver package on your local hard disk--> <classPathEntry location="E:/1/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 the automatically generated comments true: Yes: false: No--> <property name="suppressAllComments" value="true"/> </commentGenerator> <!--Database link URL, username, 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 package name and location of the model --> <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 mapping file --> <sqlMapGenerator targetPackage="mapping" targetProject="src/main/resources"> <property name="enableSubPackages" value="true"/> </sqlMapGenerator> <!-- Generate the package name and location of the DAO --> <javaClientGenerator type="XMLMAPPER" targetPackage="com.chen.mapper" targetProject="src/main/java"> <property name="enableSubPackages" value="true"/> </javaClientGenerator> <!-- The table to be generated is the table name in the database or the view name domainObjectName is the entity class name --> <table tableName="t_user" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> </context></generatorConfiguration>
Click
SpringBoot project implements hot deployment in IntelliJ IDEA
spring-boot-devtools is a module serving developers. The most important function is to automatically apply the code to the latest app.
The principle is to restart the application after discovering that the code has changed, but the speed is faster than to start it manually.
Its deep principle is to use two ClassLoaders, one Classloader loads those classes that will not change (third-party Jar packages), and the other ClassLoader loads the classes that will change, called restart ClassLoader
,In this way, when there are code changes, the original restart ClassLoader is discarded and a restart ClassLoader is recreated. Since there are relatively few classes that need to be loaded, a faster restart time is achieved.
That is, devtools will listen for file changes under classpath and will immediately restart the application (occurring at the time of saving)
1. Turn on the idea automatic make function
1. CTRL + SHIFT + A --> Find make project automatically --> Select
2. CTRL + SHIFT + A --> Find Registry --> Find and check compiler.automake.allow.when.app.running
Finally restart idea
1. Use spring-boot-1.3 to start with hot deployment functions
1. Add maven dependencies
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId><optional>true</optional></dependency>
2. Turn on hot deployment
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork>//This configuration must</configuration> </plugin> </plugins></build>
Summarize
The above is the graphic tutorial on the configuration of springboot of the intellij IDEA that the editor introduced to you. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to Wulin.com website!