IDEA Using Tutorial
Download and install
IntelliJ IDEA is introduced
IDEA, full name IntelliJ IDEA, is the Integrated development environment of Java language. IDEA is recognized as one of the best Java development tools in the industry. Especially in intelligent code assistant, code autoprompt, refactoring, J2EE support, Ant, JUnit, CVS integration, code review, innovative GUI design and so on can be said to be supernormal.
IntelliJ IDEA introduces itself on its website as follows: Excel at enterprise, mobile and web development with Java, Scala and Groovy, with all the latest modern technologies and frameworks available out of the box.
IntelliJ IDEA is mainly used to support Java, Scala, Groovy and other language development tools, while supporting the current mainstream technology and framework, good at enterprise application, mobile application and Web application development.
Main advantages of IDEA :(over Eclipse)
① Strong integration ability. For example: Git, Maven, Spring, etc. ② prompt function fast, convenient ③ prompt function wide range ④ easy to use shortcuts and code templates. For example: private static final = PSF ⑤ Precise search
IDEA official website download address:
www.jetbrains.com/idea/downlo… IDEA is available in two editions: Ultimate and Community. The flagship version is available for a 30-day free trial, while the community version is free, which is quite different from Eclipse. Two different versions of the detailed contrast, can consult website: www.jetbrains.com/idea/featur…
Detailed usage documents provided on the official website
www.jetbrains.com/help/idea/m…
The installation process
When installing the first choice to install the flagship version, community version although free, but some features are not complete
Double-click to run the installation program ideAIu-YYYY.mm. Exe:
Click Next
Select the installation directory of the file and click Next.
*The red arrowThe options pointed to represent the number of bits to choose based on your computer, in this case I chose 64 bits.The green arrowThe option pointed to represents the associated file. If you check it, it will be opened later when you double-click the.java file on your computer. It is recommended to select Unassociated.Blue arrowThe option indicated indicates whether JetBrain will automatically download a JRE. It is highly recommended that you check this box if you have not configured a JRE on your computer before. Multiple JRes can coexist on the same computer without conflicting with each other. Each program can have its own JRE. When the program is running, it searches for the corresponding JRE with a priority. It searches for the current directory first, then the parent directory, and finally in the environment variable of the system. If the jre path has already been configured in the system environment variable, it will not be a problem. If you are not sure, you are advised to automatically install a JRE when installing JetBrain. It is convenient and does not conflict with the existing environment. Multiple JRes can coexist and just take up a bit of disk space. The rest can be selected later: Click Install Click Finish
The first loading configuration
After the initial installation, the following dialog box is displayed. Select not to import the existing Settings and click [OK]
Click receive user license and click continue. Click “Do not send”
Set the theme
This is based on personal preference, or skip all and set defaults. And then you can set the theme and so on in Settings. Select Next:Default Plugins here
Set up the plugin
To set various plug-ins in IDEA, you can customize, delete, or install plug-ins that do not exist (such as those that support Scala). Do not set it here. You can also set it later through Settings in the menu bar. IDEA plug-in download address: official plugins.jetbrains.com/idea click [Next: Featured plugins]
Click Start using IntelliJ IDEA
Tool to activate
There are three activation modes of IEDA: activation code, activation server and patch cracking.
The activation code can be purchased online, and the activation time is generally one year.
The activation expiration time of the activation server depends on the stability of the server and whether the JB official has blocked it;
Cracked patches are activated by program injection and can be permanently activated (expire in 2100).
Tool Use (Getting started)
Creating a Java project
Create New Project: Create a New Project. Import Project: Imports an existing Project. Open: Opens an existing project. For example, you can open the Eclipse project. Check out from Version Control: You can Check out projects on Github or other Git-hosted servers using the project address on the server.
Select Create New Project
If you want to create a Web project, check the Web Application above. This example begins by demonstrating the creation of a simple Java project.
Select [New…] , select the location of the JDK installation path:
Select the JDK in the specified directory as the Project SDK.
After clicking “OK”, select “Next” You don’t need to check it here. Select [Next] to go to the Next page: To name and set the location of the project to be created, click Finish.
Program interface
The SRC directory under the project is similar to the SRC directory under Eclipse, where the code is stored. The.idea and project01.imL files under the project are specific to the IDEA project. This is similar to.settings,.classpath,.project files in Eclipse projects.
Bring up the toolbar and button group
Creating a Package
Then create a package in the SRC directory:
Creating a Java file (class)
New a Java Class under the package:
Whenever you create a Class, Interface, or Annotation, you select New –> Java Class and select the type of structure you’re creating in the Kind drop down box. Then declare the main method in the HelloWorld class, printing HelloWorld! , complete the test
After writing the code, do not click save. IDEA automatically saves the code.
Create a module
Small projects are less complicated than multi-module projects. A single Module structure is also supported by IntelliJ IDEA, and IntelliJ IDEA creates projects with a single Module structure by default. Create the Module: Click Next. Give the module a name and a location to save it After that, we can write code in Module SRC. SRC under Project01 is useless. I can delete it.
Delete module
Select the module you want to remove and click the minus sign
If you select the Module to be deleted, the “Delete” option will appear, which will Delete the Module from the hard disk Viewing project Configuration Enter the project structure:
Commonly used configuration
Enter the Setting screen
The directory structure is as follows:
Set the theme
Set the edit area theme
Set the automatic packet guide function
- Add unambiguous imports on the fly: Automatically import ambiguous structures
- Optimize imports on the fly: Automatically Optimize imported packages for us
Sets the separation between methods
- As shown in the red circle above, check Show Line numbers to display the number of lines. Idea of the new version is selected by default.
- Select Show Method separators, as shown in the red circle above. This line helps us to distinguish between methods.
Setting case Prompt
- IntelliJ IDEA’s code hints and supplements feature one feature: case sensitivity. As shown in the annotation above, the default is First Letter only case sensitive.
- Case sensitive: if we type stringBuffer in a Java code file, for example, IntelliJ IDEA – does not hint or supplement by default, but if we type stringBuffer it does.
- If you do not want to be case sensitive, deselect this option. (Change to None option in 2017 version of IEDA)
Setting font Styles
Modify the color of the comment
- Doc Comment – > Text: Changes the font color of document comments
- Block comment: Changes the font color of multi-line comments
- Line comment: Changes the font color of the Line comment
Set the file encoding format
Common Shortcut keys
Creating a Java Web Project (Advanced)
Creating a static Java Web(front-end development)
Right-click file or project -> New -> Module
Set the project name and location for the static Web:
Module for creating dynamic Web (Back-end Development)
Right-click file or project -> New -> Module
You must check Web Application here to create a Web project. Provide the Web project name and location. The project structure after creation is as follows:
Configuring local Tomcat
Click on the Edit Configurations
Choose Templates -> Tomcat Server -> Local, edit the template, click the “+ “button, and select Tomcat Server -> Local. You can choose TomEE Server or Tomcat Server.
Then configure the name of Tomcat and the location of the application server. Depending on the installation location of Tomcat. Use the default values (setting the browser to launch and port number) for the other locations, as shown below: Next click On Deployment -> Click + -> Artifact: After selecting the application Click back on the [Server] TAB, now: In this way, our template is configured. Next, we click the “+” button and select Tomcat Server -> Local to directly use our newly configured template, as shown below: Click [OK] to complete the configuration
Connecting to a Database
Association mode:
Fill in the database information, and Test Connection is in the gray state After filling in, click [Download Missing Driver Files] to Download the driver file from the central warehouse. Now [Test Connection] is clickable. We click it to Test the database Connection. Click [OK] to view the effect: Note: If you are using Oracle, follow the steps above
Common operations
- Icon 1: Synchronize the current database connection. This is the most important operation. After configuring the connection or using other tools to operate the database, you need to synchronize data in a timely manner.
- Icon 2: Configure the current connection.
- Icon 3: Disconnect the current connection.
- Icon 4: Displays data for the corresponding database object.
- Icon 5: Edit or modify the current database object.
Configure Maven
Maven’s configuration
Maven’s core program does not contain specific functions, just macro scheduling. Specific functions are accomplished by plug-ins. The Maven core program looks for plug-ins in the local repository. If not in the local repository it is downloaded from the remote central repository. If you do not have access to the Internet, you cannot perform Maven functions. To solve this problem, we can point Maven’s local repository to a directory that can be downloaded online.
- Maven home directory: I can specify the local Maven installation directory, because I have configured the MAVEN_HOME system parameter, so I can find IntelliJ IDEA directly. But if you don’t, you can select your Maven installation directory here. In addition, the IDEA default is not recommended here.
- User Settings File/Local Repository: We can also specify Maven’s settings.xml location and Local repository location.
Settings. XML file changes:
1. Address of local warehouse
2. Remote warehouse address
The Settings. XML file is modified as follows:
. <localRepository>D:\learn\Maven\repository-idea</localRepository> ...... <! Maven </id> <name> Aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> <! - official operations maven 2 remote warehouse - > < mirror > < id > repo2 < / id > < name > rep2 maven < / name > < url > http://repo2.maven.org/maven2/ < / url > <mirrorOf>central</mirrorOf> </mirror> ...... Copy the codeCopy the code
Maven -> Importing
- Import Maven Projects Automatically: Indicates that IntelliJ IDEA will monitor the PUM. XML file of a project in real time and change the project automatically. You are advised to select this option.
- Automatically Download: Whether source code and documentation will be Automatically downloaded when Maven imports dependencies. It is not checked by default, and it is not recommended to check, because it can speed up the project to import the dependency package from the Internet. If we need the source code and documents, we can download a dependency package online. IntelliJ IDEA supports direct download source code and documents from the public network.
- VM Options for importer: You can set the parameters of the VM to be imported. We don’t need to actively change this parameter unless the project is really slow to import and we increase this parameter.
Demonstrating using Maven
Create the corresponding Module
Select the Spring Initializr template for Spring Boot For example, Spring Initalizr is the template of the SpringBoot project.
- Group: domain name of an organization or company, in reverse order
- Artifact: Project module name
- Version: Default Maven generated Version: 0.0.1 -snapshot
Here you can temporarily not select, later development needs to be set again. Click Finish to complete the creation.
Once created, you can see the created Module on the right side of IDEA. If not, refresh it. There is also a life cycle in the directory. The common ones are clean, compile, package, and install. Install, for example, can be installed if other projects need to use this module as a dependency. Install to a local repository location.
Screenshots of files in the local repository:
Other Settings
Generate javadoc
Fill in the project or module that generated the Javadoc, output location, language, code, and so on
Locale: Input language type: zh_CN Other command line arguments: -encoding UTF-8 -charset UTF-8 error: unknown flag: date
Cancel the update
Use of plug-ins
In the installation explanation of IntelliJ IDEA, we already know that many functions of IntelliJ IDEA are realized through plug-ins. Plugins.jetbrains.com/
In IDEA, open Settings
Special attention should be paid to the fact that in domestic networks, the list of plug-ins often cannot be displayed, or the list of plug-ins is displayed, and the installation cannot be completed. Please open VPN by yourself at this time, generally can be solved. Demonstrates installing GsonFormat
As illustrated in the figure below, install the plugin in the IntelliJ IDEA plugin library online. After the installation, you will be prompted to restart before you can use the plug-in. Recommended Common Plug-ins