IDEA-jetty hot loading (class files and static resources)

1. Scenario:

    1. In the actual project development and debugging stage, repackaging and deployment affects efficiency, while hot deployment and hot loading can improve efficiency;

    2. IDEA has no automatic compilation option in the running/debugging state;


2. Jetty's maven plugin:

<!-- jetty plugin-->
<plugin>
  <groupId>org.mortbay.jetty</groupId>
  <artifactId>maven-jetty-plugin</artifactId>
  <version>6.1.5</version>
  <configuration>
    <scanIntervalSeconds>2</scanIntervalSeconds><!-- How many seconds to perform a hot deployment, set to 0 will not hot load -->
    <connectors>
      <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
        <port>8099</port>
      </connector>
    </connectors>
    <contextPath>/lalalala</contextPath>
  </configuration>
</plugin>


3. IDEA performs hot loading in the debug state.

    1. IDEA does not support automatic recompilation at runtime, and needs to be triggered manually;

   2. [Main menu]->[Build]->[Recompile ...]/[Build Project], recompile a separate class/recompile project, there are corresponding shortcut key settings command+shift key+F9/command+ F9.

    3. But if we don't want to press such a complicated button, if we just want to automatically compile the file when we save it, we can only solve it by recording macros at present.


4. Macro recording ( reproduced from other blogs )

    

Here is my flow of operation:

First click on the menu to start recording the macro

After clicking, a small green box and status bar will appear in the lower right corner

Then we can start recording, first press the shortcut key ctrl+s and then press the shortcut key ctrl+F9

After the two operations are completed, we can stop recording and save the macro. You can either click the red button in the lower right corner or go back to the menu and click stop Macro Recording
  

After stopping the recording, we have to give him a name and let him save it to the configuration.

Like this, I gave auto make, or it can be save and make, which is in line with our operation.

After clicking OK to save, we can go to the shortcut key setting of the setting panel (keymap) to set the shortcut key of the macro

In the keymap settings, we choose Macros settings, that is, macro settings. After clicking to expand, you can see the macro "auto make" we just recorded, then right-click and select "add keyboard Shortcut" to set shortcut keys for our macros

We press Ctrl+S to set the shortcut key, then a red warning will appear below, telling us that this shortcut key has been occupied by the save All operation, but don't worry, just click OK to save

When saving, you will be prompted to delete the occupied shortcut operation settings in order to set the shortcut key, directly click "Remove" to delete, and then you can save successfully.


Five, the improved version of the macro:

    1. The macro recorded in step 4 only works on java files, but does not work on resource files. Therefore, when recording a macro, you need to do one more step. Execute the shortcut key command + shift key + F9 on the resource page to hot load the resource file.



Reference documentation:

1. A temporary solution for IDEA not being able to compile in real time. . . .

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325992295&siteId=291194637