In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to master IntelliJ IDEA". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to master IntelliJ IDEA.
Create a new Java project in IntelliJ IDEA, a project can help you organize source code, tests, libraries used, build instructions, and personal settings into one unit. 1. Start IntelliJ IDEA. If you open the Welcome screen, click New Project. Otherwise, select File | New | Project from the main menu. two。 In the New Project wizard, select Java from the list on the left. 3. To develop Java applications in intellijidea, you need javasdk (JDK). If the desired JDK is already defined in IntelliJ IDEA, select it from the Project SDK list. If JDK is installed on your computer but is not defined in IDE, select Add JDK and specify the path to the JDK home directory (for example, / library/java/javavialmachines/JDK-13.0.1).
If you do not have the necessary JDK on your computer, select Download JDK. In the next dialog box, specify the JDK vendor (for example, OpenJDK), version, change the installation path if necessary, and then click Download.
In this tutorial, we are not going to use any other libraries or frameworks, so click next. Do not create a project from a template. In this tutorial, we will do everything from scratch, so click next. Name the project, for example: HelloWorld. If necessary, change the default project location and click finish.
Create package and class packages to combine classes that belong to the same category or provide similar functionality to construct and organize large applications with hundreds of classes. 1. In the Project tool window, select the src folder, press Alt + Insert, and then select Java Class2. In the Name field, type com.example.HelloWorld. HelloWorld and click OK. IntelliJ IDEA creates the com.example.HelloWorld package and the HelloWorld class.
Along with this file, IntelliJ IDEA automatically generates some content for your class. In this case, IDE inserts package statements and class declarations. This is done through a file template. Depending on the type of file you create, IDE inserts the initial code and the format expected to exist in all files of that type. For more information about how to use and configure templates, see File templates. Start coding and add main method through dynamic template
Output print method
Operation method
Package the project as a Jar package if you can see the out/artifacts folder, then you will be able to see the Jar package
Just run the packaged application and execute Jar. two。 Basics when you will build an application, then there are some basic operations that you may not know. Why use IDE? Isn't it because you want to be more efficient? Many useful features are unknown, how to improve efficiency?
Generate the cursor after the same content, a choice: specific meaning can see the following dynamic picture on the line, need to be used with shortcut keys, you can generate the cursor after the same keyword, so delete, modify and add new code is not convenient?
Windows:Alt + J
Mac: Ctrl + G
Add the cursor after all the same content in one step: use the shortcut key to generate the cursor after all the word
Windows:Ctrl + Shift + Alt + J
Mac: Ctrl + Command + G
Series cursor: method: alt + hold down the left mouse button to drag to achieve the following dynamic picture effect, efficiency max!
Add the cursor to the end of the line alt + hold down the left mouse button and drag from left to right.
Add a cursor operation at the specified location
Batch adjustment of format
Batch the code on the left side of the petition to the right code ctrl + alt + enter move the cursor to the previous line of the current line
Batch add Swagger attribute comments
Add swagger information to the left-hand side of the above image with only annotated classes
Extract a field information from multiple Json with the same structure
Extract all role fields from the left Json
3. IDEA Common Shortcut Keys there are some shortcuts used with the mouse, as well as some commonly used shortcuts. Method parameter hint
Ctrl + p is a very useful shortcut key, sometimes the method we write ourselves, or when looking at some source code, it is very useful for text case conversion.
Ctrl + shift + U collapse code / unfold code ctrl +-/ ctrl + + Global search text ctrl + shift + F quickly find and open the recently used file code ctrl + E automatic code chip ctrl + j implementation interface method ctrl + I View the subclass of the current class ctrl + h merge the current line and the next line ctrl + shfit + j jump the cursor to the previous line of the current line sometimes you need to add comments when you finish writing a line of code Or when you add comments to a class attribute, you need to skip to the previous line of the current line. This shortcut is very convenient for ctrl + alt + enter.
Idea git submits ctrl + k to delete the current line ctrl + y rewrite or to implement the interface or parent class method ctrl + o display the relationship between classes ctrl + alt + u Delete unused packagectrl + alt + o enter the settings interface ctrl + alt + s add a line ctrl + shfit + enter pop-up to the next line where the current cursor is on such a line Methods in the current class collection ctrl + F12 one of the most commonly used keyboard shortcuts, quick search method to add bookmarks
Ctrl + F11 search file ctrl + shift + n search class ctrl + n one of the most commonly used shortcut keys, the project is slowly getting bigger, there are more and more files, every time you use the mouse to find it is too inefficient to quickly generate try, if and other statements
Alt + shift + t when you try it, you will fall in love with this shortcut to extract local variables
Ctrl + alt + v extracts the currently selected code as a local variable into the implementation subclass ctrl + alt + b when using the mvc framework, often we have only one instance of the interface, and this shortcut key can be directly into the implementation class to format the code to make the code beautiful, which is something that every programmer should pay attention to, convenient for himself and others to read, self-serving idea multi-cursor selection.
Press the scroll wheel and drag the mouse up and down to ctrl + alt + Lidea batch modify the same content ctrl + alt + shift + j sometimes the data needs batch processing. For example, normally our entity classes are annotated when they are generated using reverse engineering such as mybatis, but when we use plug-ins such as swagger to display the meaning of the passing entity. If we need to write it one by one, it will be very troublesome to run the current class ctrl + shift + F10. When writing some test code, this shortcut key is particularly convenient to start a debug mode alt + shfit + F9 from multiple projects in a microservice. When multiple projects are in one project, this method is more useful. In this way, you don't have to go to one by one and save a lot of unnecessary operations to start a normal mode from multiple projects.
Alt + shfit + F10 recompile the current project ctrl + shift + F9 when you find that some problems are particularly strange, naming appears to be fine, but when the project doesn't work, just recompile and get it to see where the current class has been used.
Quickly look at the selected class, select the definition of the method, sometimes we do not want to enter the inside of the method, or enter the inside of the class to see the details, want to explore clearly on the outside, we can use this method ctrl + shift + I
One of the more powerful shortcut keys Ctrl + ~ (the button next to the exclamation mark) there are five optional operations Switch Code Formatter (switch code formatter) 1. Color Scheme (color scheme) can set some commonly used color matching, font style, you can switch 2. Code Style Scheme3. Keymap (list of shortcut keys) 4. View Mode (display mode) 5. Look and Feel (set software theme)
Idea calls up version control operation alt + ~ 4. IDEA common settings
IDEA opens multiple projects File-Settings-Appearance & Behavior-System Settings in a new window.
Modify IDEA default encoding-> UTF-8File-Settings-Editor-File Encodings
Set the unified compiler and compiled version File-Setting-Build-Compiler-Java Compiler
Set class annotation File-Editor- File and Code Templates
$end$$ can set the position where the cursor ends File-Editor- General-Auto Import
Memory usage shows that because daily development is carried out on the company's office computer, there is always not enough memory, but it is not clear how much memory IDEA takes up in real time. At this time, for some developers who don't have enough memory, they can see that the real-time memory usage is better than File-Settings-Appearance & Behavior.
Turn on hover prompt sometimes when you look at the code, if you don't know exactly what a class does, you will click in to see the comments of the class, but the powerful IDEA supports that you can see the comments and the relevant information about the class without clicking in. File-Settings-Editor-General
Ctrl+ mouse scroll modify font size IDEA also supports pressing and holding down the Ctrl+ mouse scroll like a browser to change the font size of the editing area File-- > Settings-- > Editor-- > General.
Display multiline Tab when we open more tabs, the default is hidden on the right, and when we need it, we find it on the right and then open it. IDEA supports multi-line display, so you don't always have to click on the one on the right to find the file you just opened. File-Settings-Editor-General-Editor Tabs.
Set the font and line spacing to make the code look more comfortable File-Settings-Editor-Font
IDEA GIT configuration File-Settings-Version Control-Git
IDEA MAVEN configuration File-Settings-Build-Build Tools-Maven
Maven Ali image configuration nexus* http://maven.aliyun.com/nexus/content/groups/public/ automatic compilation specific steps: top toolbar File-> Other Settings-> Default Settings-> Auto Import description: after enabling automatic compilation, combining with Ctrl+Shift+F9 will have a hot update effect. Specific steps: click Ctrl + Shift + Alt + / and then double-click Shift search to enter Registry, find compiler.automake.allow.when.app.running, and check above. Finally, if you want to know how to achieve hot deployment in SpringBoot, click SpringBoot+IDEA to achieve hot deployment tutorial: https://www.jianshu.com/p/f658fed35786 remove case sensitivity specific steps: File | Settings | Editor | General | Code Completion Case | Sensitive Completion = None cancel size sensitivity, when writing code, the automatic prompt of the code will be more comprehensive and rich. Adjust font type and font size the default white background and small fonts will affect everyone's coding experience, here specially provides a quick configuration to adjust the code window. Open the configuration, search Font, and then Font can adjust the font type, Size can adjust the font size, as shown in the figure: set the shortcut key to the same as Eclipse, many people may not be used to IDEA shortcut key, for convenience, here we set the shortcut key to be the same as Eclipse. Specific steps: File-> Settings-> Keymap-> Select Eclipse. Friends transferred from Eclipse can rest assured that they can use the specific steps of opening common toolbars: top navigation bar-View-> check Toolbar & Tool Buttons
5. Common plug-ins for IDEA
The plug-in AlibabaCloudToolkit is more suitable for small projects or for development in a test environment. The personal feeling of the production environment is not suitable. Individuals often have such a need, every time they update the test environment, they need Maven to package clean install, then copy jar package, use ftp tools to upload jar package to the test server, and then kill service, start the service java-jar, sometimes update frequently this is a very troublesome thing Cloud Toolkit is a local IDE plug-in to help developers develop, test, diagnose and deploy applications more efficiently. Through the plug-in, you can deploy local applications to the cloud (ECS, EDAS, Kubernetes, etc.) and any server with one click; and it also has built-in tools such as Arthas program diagnostics, Dubbo tools, Terminal Shell terminals, and MySQL executors. Official link: https://www.aliyun.com/product/cloudtoolkit simply said that after installing this plug-in, Idea has some automatic deployment features of Jenkins 1 installed in the Idea tool Plugins direct search installation 2 use after the installation is complete, the Aliyun button will appear in the toolbar, click the button
Then click Deploy to Host, and the add host page appears below
Click Add Host
Take my own blog as an example. After entering the configuration, click Test Connection, Succeeded appears, and click add, indicating that the addition is successful.
Then click Deploy to Host
Click Run, and idea will be packaged with maven, and then sent to the specified location of the server.
After that, you can also monitor the startup log, which is very simple, that is, in the Advanced, you can see it.
Later, there will be time to improve the role of the IDEA plug-in Git Flow plug-in: integrating Git Flow allows us to focus more on development. Git Flow: https://medium.com/@rafavinnce/gitflow-branch-guide-8a523360c053 installation
When the use is not initialized at first, click GitFlow init in the lower right foot.
Just set it directly by default. Click Ok and you can start using it.
Following the most standardized process, you can avoid falling into the pit at some point in the future. Git version management specification: master: always in production-ready state
The main branch, after all the functions of the product are realized, it is finally released in the master branch.
Read-only branches that can only be merged from release or hotfix branches and cannot be modified
All tweets on master branches should be tagged for easy traceability.
Develop: the latest development status of the next release
Main development branch, based on master branch cloning, published to the next release
Read-only branch, feature functional branch completed, merged into develop (no push)
Develop pulls the release branch and picks up the test
When the release/hotfix branch is online, merge it to develop and push it.
Feature: all the new functions are developed from develop, and merge is returned to develop after completion.
Functional development branch, based on develop branch cloning, for the development of new requirements
Merge to develop branch after feature development (cannot be pushed to remote central warehouse until it is officially launched)
Multiple feature can exist at the same time, which can be used for multi-functional synchronous development of the team. It belongs to a temporary branch and can be deleted after development.
Release: prepare the version of release, only fix bug. Get out of develop, and merge will return to master and develop when finished.
Test branch, after merging the feature branch into the develop branch, clone from the develop branch
As long as it is used to submit to the tester for functional testing, if BUG is found to be repaired in the release branch during the test, the repair will be merged into the
Develop/master branch and push complete, make label record
Temporary branch, which can be deleted when it is online.
Hotfix: if you can't wait for the release version, you have to fix the master launch immediately. Get out of master, and merge will return to master and develop when finished.
Patch branch, based on master branch clone, mainly used for BUG repair of online versions
After the repair, merge to the develop/master branch and push it to record the tag.
Modifications to all hotfix branches go to the next release
Temporary branch, which can be deleted after patch repair is online.
IDEA plug-in PlantUML1. Background previously introduced the use of Vscode to draw UML, in fact, there is a similar plug-in in idea to draw UML. PlantUML syntax: https://plantuml.com/zh/component-diagram installation plug-in installation address: https://plugins.jetbrains.com/plugin/7017-plantuml-integration after installing the official plug-in, but also need to install an additional graphviz, otherwise some complex use case diagrams will not be able to show. Graphviz: https://graphviz.org/download/2. windows installation choco install graphviz uses the new file-PlantUML File-select the type you want to create
Flow chart
Flowchart CODE
Use case diagram
Use case diagram Code @ startumlleft to right directionactor ordinary as Useractor Review as Aduitoractor Editing as Editoractor Marketing as Marketingactor Operation as Operatoractor Administrator as AdminAdmin-> Userrectangle Community {User-- (View articles) User-- (post management)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.