当前位置:网站首页>Idea of [developing killer]

Idea of [developing killer]

2022-07-01 12:50:00 51CTO

【 Develop big killer 】 And Idea_docker

Rapid delivery must have good tools to improve development efficiency , This article introduces the development of heavy killer IntelliJ IDEA. Including those we have developed for many years Bottom pressing tool It's all open , The following is the welfare time ~

  • win+linux Dual system , At the same time, it supports sandbox repeated verification !
  • Idea Common configurations and skills sharing
  • Idea Integrate docker, Fully automatic publishing 、 Graphical management application !

One 、Win10 Development machine installation preparation

If a worker wants to do a good job, he must sharpen his tools first , Start idea Before using , It is also necessary to optimize the local development machine , Provided here win+linux The perfect solution of dual system and sandbox And other pre supporting software !

win10 achieve win+linux Dual system , And the experimental environment with sandbox !

【 Develop big killer 】 And Idea_java_02
The operating system comes with cmd It's relatively weak , Sometimes we need multiple windows 、 Run the command in the specified directory 、 image linux Integrate or switch many different shell It's hard to do it when . This product is launched by Microsoft with a low profile , Not included , In the Microsoft app store and github You can download freely on 、 Free trial , Here is a big recommendation !

【 Develop big killer 】 And Idea_docker_03

Windows Terminal Official download address :  Microsoft Store  or   GitHub

When using , In any directory , Right click to see open in terminal, However, the goose is even better , Support on the command line ssh、 And bring it with you Ubuntu etc. linux System , Let our development learning connect seamlessly !

【 Develop big killer 】 And Idea_docker_04

After restart, we download it from the app store ubuntu, So you can do it win10 Swim down java The world ~
【 Develop big killer 】 And Idea_java_05

You need to set a password for the first time , Then you can use the application menu , or terminal Open directly in , If you don't like it, you can also download other versions or other distributions at will , Such as fedora、opensuse wait
【 Develop big killer 】 And Idea_java_06

【 Develop big killer 】 And Idea_ide_07

The sandbox with its own program is opened on the top , Let's try all kinds of tools at will without psychological burden ! After the sandbox is opened 【 Start 】 Can be found in the menu , Very comfortable to use , Turn off automatic cleaning after use .
【 Develop big killer 】 And Idea_docker_08

The configuration you may need is memory amplification 、 Mount Host Directory , Reference code is provided here

<!--  Save as XXX.wsb file , Here is the memory configuration , The host machine 、 Sandbox directory for reference  -->
<Configuration>
	<MemoryInMB>8196</MemoryInMB>
	<MappedFolders>
		<MappedFolder>
			<HostFolder>G:\ development tool </HostFolder>
			<SandboxFolder>c:\ development tool </SandboxFolder>
			<ReadOnly>false</ReadOnly>
		</MappedFolder>
	</MappedFolders>
</Configuration>

     
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.

jdk Installation configuration

Download from official website 、 install , routine 1.8 The version of is enough , Suggest JAVA Class tools are installed in the same directory , Such as d:\java\.

When JDK、JRE After installation , The environment variable configuration is supplemented here , In this way, we can run directly in many places cmd 了 ~

Environment variable configuration , windows System settings , My computer -》 Right click Properties -》 Advanced settings -》 environment variable

【 Develop big killer 】 And Idea_java_09

【 Develop big killer 】 And Idea_java_10

The above operations are mainly used to run directly from the command line java、javac、jar、mvm Wait for the order
【 Develop big killer 】 And Idea_docker_11

Maven Installation configuration

Download and install  Apache Maven Download from the official website zip package , Unzip to D:/JAVA/ Next , And configure environment variables AVEN_HOME, Add to PATH in

【 Develop big killer 】 And Idea_docker_12

test : Verify that the command line is available

【 Develop big killer 】 And Idea_java_13

To configure : To configure Aliyuan accelerates 、 Local warehouse cache , hinder idea Applying this configuration can Unified

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <mirrors>
  	<mirror>
		<!--This sends everything else to /public -->
		<id>nexus-aliyun</id>
		<mirrorOf>*</mirrorOf>
		<name>Nexus aliyun</name>
		<url>http://maven.aliyun.com/nexus/content/groups/public</url>
	</mirror>
  </mirrors>
  <localRepository>d:\repository</localRepository> 
</settings>

     
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.

notes : This document is in c Disk user directory .m2 Under the table of contents , namely %USERPROFILE%\.m2\settings.xml

Tomcat 8.5 Installation configuration

take  apache-maven-3.8.6-bin.zip Download and unzip to D:/java

test , double-click tomcat/bin/startup.bat, Check whether the command line reports an error , Whether the browser can normally access 8080 port , If there is a conflict , modify conf The configuration file , Replace 8080 For other ports
【 Develop big killer 】 And Idea_docker_14

【 Develop big killer 】 And Idea_java_15

Two 、IntelliJ Idea install 、 To configure

idea As a commercial software , With many third-party tools , However, it is suggested that we prepare by ourselves , If there are better tools in the future, we can smoothly switch , Many similar events have happened , For example, it was very popular before JBuild、eclipse、MyEclipse wait

Provided on the official website 30 Day trial enterprise 、 Community Edition , You can download tests , Download IntelliJ IDEA

【 Develop big killer 】 And Idea_docker_16

The installation path is unified in the same directory for easy management , Remember to switch the pre installed JDK~

Idea Common configuration

  • modify idea The code prompt shortcut key is Alt+/

【 Develop big killer 】 And Idea_ide_17

  • modify idea Code reminder ignores case
    【 Develop big killer 】 And Idea_ide_18

  • add to yaml plug-in unit , convenient application.yml Documentation
    【 Develop big killer 】 And Idea_ide_19

  • correct maven by alibaba Source + Local warehouse acceleration

The configuration file is above maven In the chapter

【 Develop big killer 】 And Idea_java_20

  • Change the theme to white classic , Convenient for personal habits

    ![【 Develop big killer 】 And Idea_java_21](file://G:\SynologyDrive%E6%88%91%E7%9A%84%E4%B8%AA%E4%BA%BA%E5%B7%A5%E4%BD%9C%E9%BB%91%E9%A9%AC%E5%BE%AE%E6%9C%8D%E5%8A%A115D\Day01-%E9%A1%B9%E7%9B%AE%E6%90%AD%E5%BB%BA.assets\image-20211012193438008.png?lastModify=1650964735?lastModify=1656573818)

  • Add a console highlighting plug-in Grep Console 【 Develop big killer 】 And Idea_java_22

attach : Here we add the installation package collected online , Do you know

idea Annotation specifications

  • Three commonly used Java Annotation mode

Variable comment

//  declare constant 
int number;

     
  • 1.
  • 2.

Class notes

package com.example.demo.controller;

/** * @description: TODO * @return: * @author: eric [email protected] * @date: 5/25/2022 */
public class Test2 {
}

     
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.

Method notes

/*** * @description: TODO * @return: void * @author: eric [email protected] * @date: 2022-05-25, Wed, 14:38 */
public void test(){
	// TODO
}

     
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.

idea Comment template

Class template ( When new )
Set the path :File-Settings-Editor-File and Code Templates-Incudes-File Header Use ready-made , New if not , The contents are as follows

/** * @className: ${NAME} * @description: TODO  Class description  * @author: eric [email protected] * @date: ${DATE} ${TIME} **/

     
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.

【 Develop big killer 】 And Idea_docker_23

Method template ( Set carriage return auto generation )

Set the path :File-Settings-Editor-Live Templates Next add a new template group , Name customization JavaTemplateGroup, This template group creates a new template , Set up Abbreviation Configure to *,option Under the expand Set to carriage return generation , Three of these parameters are as follows :

  • return, methodReturnType()
  • date, date(“Y-MM-d, E, H:m”) This query comes from GG, Parameter empty only has date
  • param as follows :
groovyScript("def result=''; def params=\"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList(); for(i = 0; i < params.size(); i++) {result+='* @param: ' + params[i] + ((i < params.size() - 1) ? '\\n ' : '')};return result", methodParameters()) 

     
  • 1.
  • The template is as follows , Be careful , want Missing a slash
*  
 $param$  
 * @description: TODO  
 * @return: $return$  
 * @author: eric [email protected]  
 * @date: $date$  
 */

     
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.

【 Develop big killer 】 And Idea_java_24
This step involves a lot of configuration ! Set it up once , You can use it happily later ~

3、 ... and 、SpringBoot Integrate

  • newly build spring initializr engineering , choice jdk8, sping/web

【 Develop big killer 】 And Idea_ide_25

  • add to application Below the level controller.TestController.java
package com.example.demo.controller;  
  
import org.springframework.web.bind.annotation.GetMapping;  
import org.springframework.web.bind.annotation.RestController;  
  
@RestController  
public class TestController {  
  
    @GetMapping("/test")  
    public String test(){  
        return "hello springboot";  
    }  
}

     
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • Upper right corner bug start-up ,web visit
    【 Develop big killer 】 And Idea_ide_26

highlight !IDEA And Docker Integration of remote servers

There are many detours here , It's using idea2021 Version of , I can't live or die , It was used 2022.1 The latest version of is OK 了 ~

Step one : Docker The server is open 2375 port

ssh Configure on the server 、 Restart the service and verify

vim /lib/systemd/system/docker.service# modify ExecStart This line 
ExecStart=/usr/bin/dockerd  -H tcp://0.0.0.0:2375  -H unix:///var/run/docker.sock


systemctl daemon-reload
systemctl restart docker

curl localhost:2375/info  // If you can respond normally json The message represents the success of opening 

     
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.

【 Develop big killer 】 And Idea_docker_27

Step two : Idea To configure Docker

In this step, you must see the prompt at the bottom that the connection is successful !
【 Develop big killer 】 And Idea_docker_28

Step three : Modify the project pom To configure

add to dockerFile, Agreed specifications , The documents are stored in java Source code level directory

【 Develop big killer 】 And Idea_java_29

FROM java:8  
COPY demo.jar /usr/local/  
WORKDIR /usr/local/  
CMD java -jar demo.jar

     
  • 1.
  • 2.
  • 3.
  • 4.

modify pom file , add to properties, add to plugin

<properties>  
    <docker.image.prefix>lzh</docker.image.prefix>  
</properties>


  
<build>  
    <finalName>demo</finalName>  
    <plugins>        <plugin>            <groupId>org.springframework.boot</groupId>  
            <artifactId>spring-boot-maven-plugin</artifactId>  
        </plugin>  
  
  
        <plugin><!-- Make docker mirrored maven plug-in unit -->  
            <groupId>com.spotify</groupId>  
            <artifactId>docker-maven-plugin</artifactId>  
            <version>1.2.2</version>  
            <executions>                <execution>                    <id>build-image</id>  
                    <phase>package</phase>  
                    <goals>                        <goal>build</goal>  
                    </goals>                </execution>            </executions>            <configuration>                <imageName>${docker.image.prefix}/${project.artifactId}</imageName><!-- Mirror name -->  
                <imageTags>  
                    <imageTag>latest</imageTag>  
                </imageTags>                <dockerDirectory>src/main/docker</dockerDirectory><!--Dockerfile directory -->  
                <dockerHost>http://192.168.20.151:2375</dockerHost><!--docker The host address -->  
                <resources>  
                    <resource><!-- The configuration here is after packaging jar Where it is -->  
                        <targetPath>/</targetPath>  
                        <directory>${project.build.directory}</directory>  
                        <include>${project.build.finalName}.jar</include>  
                    </resource>                </resources>            </configuration>        </plugin>  
  
    </plugins></build>

     
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.

This implementation maven Panel clean、package operation , Deo gratias , I saw it docker Layered compilation !
【 Develop big killer 】 And Idea_docker_30

Step four : Joint commissioning and test
stay idea below service in , find docker, If it doesn't start, click , Find what we compiled and uploaded image, Right click to create a container , This automatically generates Run configuration
【 Develop big killer 】 And Idea_java_31

Set the image name for the boot configuration 、 Container name , And add operating parameters , You can also preview , The following can also be set before startup maven Recompile and package , This completes Automation !
【 Develop big killer 】 And Idea_ide_32

After modifying the code , Re execution , You can see that the page has changed in time

【 Develop big killer 】 And Idea_ide_33

At the end

idea It's a good tool , It's easy to see docker journal 、 Graphical maintenance , Very good !

【 Develop big killer 】 And Idea_java_34

Interaction with you is the driving force of my continuous creation !【 One button three links is the ladder of human progress !】

原网站

版权声明
本文为[51CTO]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/182/202207011232346117.html