IDEA sums up the code of sharpening the knife

If you want to be good at your work, you must first make use of your tools. At present, countless Java programmers have replaced Eclipse in the stone age with InteliJ IDEA, a modern intelligent development tool. It's a great time to write code (joke, each has its own advantages, depending on personal habits)

But every time I see other people using IDEA, I will find that, wow, I can still operate like this, and every time the registration code fails, I regret that I am using pirated software and "why don't I make more money to support the genuine", and then I look for the registration code everywhere, so here comes this article ~ ~... Installation and writing of hello world deployment to the server are not recorded,

Click like + collect to learn the series, articles are included in GitHub JavaEgg , N-line Internet development necessary skill weapon spectrum

InteliJ IDEA introduction

IDEA, the full name of 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 the intelligent code assistant, code automatic prompt, refactoring, J2EE support, Ant, JUnit, CVS integration, code review, innovative GUI design and other functions can be said to be extraordinary.

IDEA is a product of JetBrains. There are other products under the company, such as WebStorm, DataGrip, GoLand

advantage

  • Strong integration capability. For example: Git, Maven, Spring, etc
  • Prompt function is fast and convenient
  • Wide range of prompt functions
  • Easy to use shortcut key and code template private static final psf
  • Precision search (IDEA will index your source code)
  • Do not need frequent Ctrl+S (auto save)
  • Built in decompiler, easy to view source code

In Eclipse, we have the concepts of workspace and Project. In IDEA, we only have the concepts of Project and Module. Workspace in Eclipse is equivalent to Project in IDEA, and Project in Eclipse is equivalent to Module in IDEA

Terminology comparison between IDEA and Eclipse

Eclipse IntelliJ IDEA
Workspace Project
Project Module
Facet Facet
Library Library
JRE SDK
Classpath variable Path variable

Template

Live Templates

Its principle is to configure some common code abbreviations. When inputting abbreviations, you can see the predefined fixed mode code, which greatly improves the development efficiency and also increases the personalization. The simplest example is System.out.println() when you type sout in Java;

Editor – General – Postfix Completion view the existing template (not modifiable)

Editor - Live Templates view or customize templates (you can add method comments, class comments)

*
 * @description:
 * @param $param$
 * @return $return$
 * @date $time$ $date$
 **/

Class comments are generally set through File Setting Editor Live Templates File and Code Templates

breakpoint debugging

Are bug s written every day, so this function must be used

Configure common debugging properties and behaviors: Settings/Preferences | Build, Execution, Deployment | Debugger

1. Breakpoint type

There are four types of breakpoints:

  1. Line Breakpoints: the most frequently used method, which can be set on any executable code line
  2. Method Breakpoints: suspend a program when entering or exiting a specified method or one of its implementations, allowing you to check the entry / exit conditions of a method
  3. Field Watchpoints: suspends a program when a specified field is read or written. It should be noted that only writing will stop by default. To stop reading, you need to right-click the breakpoint and tick the Field access of the Watch
  4. Exception Breakpoints: suspends a program when Throwable or its subclasses are thrown. You can add specific types of exceptions in Java Exception Breakpoints in Run View Breakpoints. In this way, the program will stop as soon as the exception occurs

2. Set breakpoint

Left click on the line number bar (Shortcut: Ctrl+F8)

Set exception breakpoint

Click View Breakpoints on the left side of the Debug tool window Or the shortcut key Ctrl+Shift+F8 can be used to create a new exception detection or to detect all the exceptions (Any Exception), so as long as the program has corresponding exceptions, it will be suspended

Conditional breakpoint

Sometimes when we are processing data circularly, we may only care about the data of a certain condition, so we can right-click the breakpoint position and set the breakpoint condition. (below, suspend the program when i==6)

Multithreaded breakpoint

When debugging multithreaded code, it can only be debugged on a serial basis, because when IDEA is in Debug, the default blocking level is ALL, which blocks other threads, and it will only take other threads when the current debugging thread is finished. If it is a line of a lambda expression, as shown in the following figure, you can choose the breakpoint type.

You can select Thread (right-click breakpoints) in View Breakpoints, so that Frames can switch threads for debug ging.

3. Step by step procedures

  • Step over -- step over. If the current line breakpoint is a method, it will not enter the current method body
  • step into -- step in. If the current line breakpoint is a method, it will enter the current method body, which is generally used to enter the user-defined method and will not enter the official class library
  • force step into Shift+Alt+F7 -- force step into any method, which can be used to enter the official class library when viewing the underlying source code
  • Step out shift + F8 -- step out, exit from the stepped in method to the method call
  • Drop frame -- back to the previous step
  • Run to cursor Alt + F9 -- run to the cursor, you can locate the cursor to the line you need to view, and then use this function, the code will run to the cursor line without breaking the point

Breakpoint has many functions. It can analyze the heap object in JVM, Stream operation in Java8, and leave a transport gate... TODO

Some big guy summed up: Using Debug in Intellij IDEA

Official course: https://www.jetbrains.com/help/idea/debugging-code.html

Configure Tomcat remote debugging

Sometimes there are problems caused by server differences, which are not easy to troubleshoot. At this time, you want to debug the code on the server remotely.

① Configure tomcat, and add a section of settings at the top of catalina.sh under tomcat/bin

-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9527

② IDEA settings

③ After launching remote tomcat on IDEA, you can debug it

There is another way to copy the contents of Startup/Connection to Java? Opts without trying

bookmark

Bookmarks can easily record the call link of the code when looking at the source code or big guy code.

There are two kinds of bookmarks: anonymous bookmarks (can be numerous) and tag bookmarks (bookmarks with number or letter mnemonics)

Operation Bookmarks: Navigate | Bookmarks can create anonymous bookmark Toggle Bookmark. Create a technical bookmark Toggle Bookmark With Mnemonic and view the tag Show Bookmarks

Plug-in unit

  • Lombok -- develop artifact to simplify your entity class

  • Maven Helper -- a good helper for displaying maven's dependency tree and handling conflicts

  • . ignore -- ignore files that do not need to be submitted

  • Findbugs idea - Code Review

  • Alibaba Java Coding Guidelines -- Alibaba's development and design specifications

  • Alibaba Cloud Toolkit helps developers develop, test, diagnose and deploy applications more efficiently. Through plug-ins, local applications can be deployed to any server or cloud with one click, and there are also built-in tools such as Arthas diagnosis, Dubbo tool, Terminal terminal, file upload, function calculation and MySQL executor

  • Easy Code -- a code generation plug-in supporting custom templates

  • restful toolkit -- restful service development assistant tool set (Amway, which can be viewed directly in RestServices on the right, restful interface of all projects, and can also be searched globally through Ctrl)

IDEA theme and plug-in leaderboard: https://plugins.jetbrains.com/search?orderBy=downloads&products=idea

activation

For personal study only~~

  1. Download the patch file jetbrains-agent.jar and place it in the bin directory of the Idea installation directory, https://pan.baidu.com/s/1Zy-vQGOdKoqDdB8sWIcQOg

  2. Free trial, enter IDEA, click * * Help - Edit Custom VM Options * * in the top menu bar, add - javaagent in idea.exw.vmoptionos file: D: \ program files \ JetBrains \ IntelliJ IDEA 2019.2.4 \ bin \ jetbrains-agent.jar (change to your jar package directory), and restart

  3. After restarting IDEA, open * * Help Register * * and fill in the License Server, http://jetbrains-license-server In case of failure, enter the registration code below

520E5894E2-eyJsaWNlbnNlSWQiOiI1MjBFNTg5NEUyIiwibGljZW5zZWVOYW1lIjoicGlnNiIsImFzc2lnbmVlTmFtZSI6IiIsImFzc2lnbmVlRW1haWwiOiIiLCJsaWNlbnNlUmVzdHJpY3Rpb24iOiJVbmxpbWl0ZWQgbGljZW5zZSB0aWxsIGVuZCBvZiB0aGUgY2VudHVyeS4iLCJjaGVja0NvbmN1cnJlbnRVc2UiOmZhbHNlLCJwcm9kdWN0cyI6W3siY29kZSI6IklJIiwicGFpZFVwVG8iOiIyMDg5LTA3LTA3In0seyJjb2RlIjoiUlMwIiwicGFpZFVwVG8iOiIyMDg5LTA3LTA3In0seyJjb2RlIjoiV1MiLCJwYWlkVXBUbyI6IjIwODktMDctMDcifSx7ImNvZGUiOiJSRCIsInBhaWRVcFRvIjoiMjA4OS0wNy0wNyJ9LHsiY29kZSI6IlJDIiwicGFpZFVwVG8iOiIyMDg5LTA3LTA3In0seyJjb2RlIjoiREMiLCJwYWlkVXBUbyI6IjIwODktMDctMDcifSx7ImNvZGUiOiJEQiIsInBhaWRVcFRvIjoiMjA4OS0wNy0wNyJ9LHsiY29kZSI6IlJNIiwicGFpZFVwVG8iOiIyMDg5LTA3LTA3In0seyJjb2RlIjoiRE0iLCJwYWlkVXBUbyI6IjIwODktMDctMDcifSx7ImNvZGUiOiJBQyIsInBhaWRVcFRvIjoiMjA4OS0wNy0wNyJ9LHsiY29kZSI6IkRQTiIsInBhaWRVcFRvIjoiMjA4OS0wNy0wNyJ9LHsiY29kZSI6IkdPIiwicGFpZFVwVG8iOiIyMDg5LTA3LTA3In0seyJjb2RlIjoiUFMiLCJwYWlkVXBUbyI6IjIwODktMDctMDcifSx7ImNvZGUiOiJDTCIsInBhaWRVcFRvIjoiMjA4OS0wNy0wNyJ9LHsiY29kZSI6IlBDIiwicGFpZFVwVG8iOiIyMDg5LTA3LTA3In0seyJjb2RlIjoiUlNVIiwicGFpZFVwVG8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PL9GVToUNxc0wcuTil8mqveWcSQCHYxsIaUajWLpFzoO2AhK4mfYBSStAqEjoXRTuj17mo8Q6M2SHOcwIDAQABo4GZMIGWMAkGA1UdEwQCMAAwHQYDVR0OBBYEFGEpG9oZGcfLMGNBkY7SgHiMGgTcMEgGA1UdIwRBMD+AFKOetkhnQhI2Qb1t4Lm0oFKLl/GzoRykGjAYMRYwFAYDVQQDDA1KZXRQcm9maWxlIENBggkA0myxg7KDeeEwEwYDVR0lBAwwCgYIKwYBBQUHAwEwCwYDVR0PBAQDAgWgMA0GCSqGSIb3DQEBCwUAA4ICAQBonMu8oa3vmNAa4RQP8gPGlX3SQaA3WCRUAj6Zrlk8AesKV1YSkh5D2l+yUk6njysgzfr1bIR5xF8eup5xXc4/G7NtVYRSMvrd6rfQcHOyK5UFJLm+8utmyMIDrZOzLQuTsT8NxFpbCVCfV5wNRu4rChrCuArYVGaKbmp9ymkw1PU6+HoO5i2wU3ikTmRv8IRjrlSStyNzXpnPTwt7bja19ousk56r40SmlmC04GdDHErr0ei2UbjUua5kw71Qn9g02tL9fERI2sSRjQrvPbn9INwRWl5+k05mlKekbtbu2ev2woJFZK4WEXAd/GaAdeZZdumv8T2idDFL7cAirJwcrbfpawPeXr52oKTPnXfi0l5+g9Gnt/wfiXCrPElX6ycTR6iL3GC2VR4jTz6YatT4Ntz59/THOT7NJQhr6AyLkhhJCdkzE2cob/KouVp4ivV7Q3Fc6HX7eepHAAF/DpxwgOrg9smX6coXLgfp0b1RU2u/tUNID04rpNxTMueTtrT8WSskqvaJd3RH8r7cnRj6Y2hltkja82HlpDURDxDTRvv+krbwMr26SB/40BjpMUrDRCeKuiBahC0DCoU/4+ze1l94wVUhdkCfL0GpJrMSCDEK+XEurU18Hb7WT+ThXbkdl6VpFdHsRvqAnhR2g4b+Qzgidmuky5NUZVfEaZqV/g==
  1. Help - About, done

Reference resources

IntelliJ IDEA 2019.3 Official Guide https://www.jetbrains.com/help/idea/installation-guide.html

Activation of idea2019 https://segmentfault.com/a/1190000021488264

You may be able to improve your skills after this cup of Java

Keywords: Programming Java Eclipse IntelliJ IDEA Tomcat

Added by glansing on Tue, 21 Jan 2020 06:20:21 +0200