当前位置:网站首页>8 software engineering environment
8 software engineering environment
2022-06-30 00:09:00 【Mayor Macondo】
Software engineering environment
Third party Library
Concept
️ After a programming language installs the development environment , Default will provide API. besides , A third party can also provide a code base ( We call it a third-party library , It's usually jar Format ), We can provide through a third-party library API To use some existing functions , You don't need to do it yourself ;
jar File what ?
️ jar Files are third-party libraries , It's a compressed file , You can use the decompression software to open , It contains class file , That is, compiled , Can be found in JVM Bytecode running on ;
️ One Java When the program realizes some functions based on a third-party library , Change the third-party library to this Java Program dependent packages ;
Third party libraries are API Do you ?
️ API: namely application programming interface, Application program interface ;
️ A third-party library is one that provides API The warehouse of ;
How to use third-party libraries ?
️ stay Java in , Using third party libraries , Mainly reflected in the development Java Introduce dependencies when code ( Dependency is the resource or tool support used in development );
1、 stay cmd Third party libraries are used in
️ We try to use dependency to change the font printed by the code output to color ;
️ First write the following with a normal text editor Java Save the code locally :
//import Introduce dependencies
import org.fusesource.jansi.AnsiConsole;
import static org.fusesource.jansi.Ansi.Color.*;
import static org.fusesource.jansi.Ansi.ansi;
public class Main {
public static void main(String[] args) {
AnsiConsole.systemInstall();
int lineNumber = 0;
System.out.print( ansi().fg(MAGENTA).a(++lineNumber));
System.out.println( ansi().fg(CYAN).a(" interviewer :").fg(RED).a(" What programming languages do you know ?") );
System.out.print( ansi().fg(MAGENTA).a(++lineNumber));
System.out.println( ansi().fg(BLUE).a(" I : ").fg(GREEN).a(" Master C、C++、Java、HTML、JavaScript Other languages , Spelling of words ") );
System.out.print( ansi().fg(MAGENTA).a(++lineNumber));
System.out.println( ansi().fg(CYAN).a(" interviewer :").fg(RED).a(" Is this ? What kind of system ?") );
System.out.print( ansi().fg(MAGENTA).a(++lineNumber));
System.out.println( ansi().fg(BLUE).a(" I : ").fg(GREEN).a(" Master Windows、Mac、Linux System , Shutdown of ") );
AnsiConsole.systemUninstall();
}
}
️ Save the above code , Get into cmd Compile ;

️ There was an error compiling ;
️ Follow the prompt , Because the dependent package cannot be found , So something went wrong , At this time, we will introduce dependency packages :
javac -cp "D:\CodeResource\Maven_repository\Repository\Maven\org\fusesource\jansi\jansi\2.3.3" Main.java
️ The operation results are as follows

️ Look at the prompt message, it seems that the coding format is wrong , Then enter the following code :
java -cp "D:\CodeResource\Maven_repository\Repository\Maven\org\fusesource\jansi\jansi\2.3.3" -encoding utf-8 Main.java
️ After running Main.java Generate a in the directory Main.class file ;

️ Enter the following command again :
java -cp ".;D:\CodeResource\Maven_repository\Repository\Maven\org\fusesource\jansi\jansi\2.3.3" Main
#.; Represents the current path
️ The output is :

Building tools
background
️ It can be seen from the above operation that , We just want to output color Fonts , The operation is so complicated , If you want to do something more fancy , That workload doesn't just take care of people emo ah ; So in order to make programming more convenient , Then there is the project construction tool ;
Common project building tools
️ about Java For projects , There are three kinds of construction tools that are used more :
️ Ant: An older build tool , You need to make your own compilation path when building 、 Resource path, etc , Depending on the package, you still need to download it yourself , The current mainstream projects are no longer used ;
️ Maven: take “ Convention due to configuration ” Thought , Agree on the compilation path 、 Resource path, etc , Dependent packages can be downloaded from the network ,Maven Based mainly on XML File ; at present Java Most server-side projects use Maven To build ;
️ Gradle: and Maven The function is very similar , Just take based on Groovy Script language DSL Syntax to configure , Almost all Android development uses Gradle;
About maven
️ Maven Is a project building tool , To create a project, just follow Maven standard ( be called Maven project ), You can use Maven Come on Conduct management : compile , Packing, etc .
maven install
️ Download decompression , Download at : edition 3.6.3;
️ After downloading, unzip it to any folder , After decompression, open the structure as follows :

Configure environment variables
️ Right click ” This computer “, Click on ” attribute “, And open ” Advanced system setup “ Medium ” environment variable “, add to Maven environment variable ;
️ First define Maven Root path variables M2_HOME;
️ And then Path In the environment variables , add to Maven Tools bin The directory is the global command path ;
️ Check whether the installation configuration is successful ;
maven Introduce
Global dependency management
️ maven Dependent packages can be introduced into the project ;
️ When introducing dependent packages , Local preference maven Search in warehouse , It's not time to search , Then search in the remote warehouse ;
Local warehouse configuration
️ find maven In the root directory conf Catalog , find setting.xml file ;
️ Open with Notepad tool ;
️ Find the following code :

️ Add the code in the red box to the position in the figure ( The path needs to be changed );
️ In this case, our local warehouse will be configured , In the future, put the downloaded dependent packages into this path ;
stay IDEA Middle configuration maven Local repository
️ open IDEA, Open up a project ;
️ Click on the file - Set up – New project settings - New project setup
️ Click on the building 、 perform 、 Deploy - Building tools -maven
️ Find... In the right interface maven The main path , Change to what you downloaded maven Storage path of tools ;
️ Of course, the user settings file and the local repository should also be rewritten , The user set the file path to the above modified setting.xml Path to file , The local warehouse path is the path of the local warehouse above ;

establish maven project
️ open IDEA, Click new project , choice maven(IDEA Different versions have different layouts );

️ Click next

️ The name and location can be set arbitrarily ;
️ Group ID: organization id、 Organization name , Generally use the company's domain name , Such as com.alibaba; At the same time, according to the specification , His writing java All under such a bag ;
️ workpiece ID: product id、 Product name , A project is a product , Therefore, the project name is generally used , More than one English - interval ;
️ edition : Version number of the product , There may be multiple versions of this project available to others ;
️ After creation , Look at the directory structure on the left ;

️ main In the catalog Java The directory is used to store the Java Code ;
️ main In the catalog resources Directory is used to store configuration files for development ;
️ test In the catalog java The directory is used to store unit tests Java Code ;
️ The manual in test Create one in the directory resources Catalog , Used to store test resources ;
️ Try to create a Java Class and compile , Observe the change of directory structure on the left ;
️ stay src/main/resources Under the table of contents , Create a profile ( Any file will do , The following is the created test.xml file );
️ stay src/main/java Under the table of contents , Create an arbitrary class , To write main After the method runs , The compilation structure will be generated , Here's the picture ;

️ Catalog target Under the classes Catalog , Write for us Java Class to class The path where the file is stored ;
️ At the same time, the path also stores the xml file ;
maven Project configuration
️ Build on us maven In the project , There is one pom.xml file , This is maven The configuration file for the project ,maven The project construction tool is based on this configuration file to maven Project management ;
️ The xml file The format of is called ” Project object model “ The concept of (Project Object Model, abbreviation POM), therefore Maven Name this file pom.xml;
️ stay IDEA Click to open the xml file ;
️ Find... In the code <maven.compiler.source> and <maven.compiler.target>, Change the numbers in both labels to 1.8,1.8 We use jdk Version of ;
️ find <dependencies> label , Change the content to the following code ( If there is no such label , Directly copy and paste the modified code into </project> above );
<dependencies>
<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.49</version>
</dependency>
</dependencies>
maven Life cycle of
️ stay IDEA In the rightmost sidebar , Click on maven, find Life cycle Catalog ;
️ clean: Used to delete target Catalog ;
️ compile: Compile development code and resource files ;
️ package: Package the whole project ;
️ deploy: Upload the project to the private server warehouse ;
The dependent resources of software runtime
Runtime environment
️ about Java Procedure ,JRE Is the necessary runtime environment ;
️ JDK yes Java The environment needed for program development ,JDK Contains JRE;
Program code
️ about Java Procedure ,class The file is the program code needed for the runtime ;
External resources
️ External resources include : database 、 File resources, etc ;
Internal resources
️ about Java Procedure , Files to be used in the run time , except class The documents , All belong to internal resources ;
journal
️ In the production environment , If there are no log files , It's almost impossible to locate the problem with the program ;
️ JDK yes Java The environment needed for program development ,JDK Contains JRE;
Program code
️ about Java Procedure ,class The file is the program code needed for the runtime ;
External resources
️ External resources include : database 、 File resources, etc ;
Internal resources
️ about Java Procedure , Files to be used in the run time , except class The documents , All belong to internal resources ;
journal
️ In the production environment , If there are no log files , It's almost impossible to locate the problem with the program ;
边栏推荐
- Label Troubleshooting: unable to open the marked image
- 西门子低代码 9.14版本: 满足不同需求
- Andorid source build/envsetup. SH details to know
- How to view the CPU cores and threads in win11? Win11 view the tutorial of how many cores and threads the CPU is
- Clone undirected graph [bfs accesses each edge but not only nodes]
- DOM 知识点总结
- Binary search tree 230 The element with the smallest K in the binary search tree 1038 From binary search tree to larger sum tree
- Mysql:sql overview and database system introduction | dark horse programmer
- Gradle serialization 7- configuration signature
- Leetcode (633) -- sum of squares
猜你喜欢

Exploration and Practice on the future direction of byte cloud database

Root cause of glideexception: failed decodepath{directbytebuffer- > gifdrawable- > drawable}
![[Shangshui Shuo series] day 8](/img/66/2aaa82f122612db1775bdd45556d97.png)
[Shangshui Shuo series] day 8

Color space conversion in video tonemapping (HDR to SDR) (bt2020 to bt709, YCbCr, YUV and RGB)

Cloud native enthusiast weekly: cool collection of grafana monitoring panels

Project 1: deploy lamp ECSHOP e-commerce platform

Construction of module 5 of actual combat Battalion

这次的PMP考试(6月25日),有人欢喜有人忧,原因就在这...

FPGA Development (2) -- IIC communication

6.29 problem solving
随机推荐
After 8 years of polishing, "dream factory of game design" released an epic update!
Solr基础操作8
New CorelDRAW technical suite2022 latest detailed function introduction
Unity about failure (delay) of destroy and ondestroy
Matlab exercises -- program control process exercise
Web APIs environment object - dark horse programmer
我想知道今天还可以开户么?另外想问,现在在线开户安全么?
Andorid source build/envsetup.sh 该知道的细节
漫画安全HIDS、EDR、NDR、XDR
请指教同花顺软件究竟是什么?究竟网上开户是否安全么?
视频ToneMapping(HDR转SDR)中的颜色空间转换问题(BT2020转BT709,YCbCr、YUV和RGB)
golang7_ TCP programming
Binary search tree 230 The element with the smallest K in the binary search tree 1038 From binary search tree to larger sum tree
Sword finger offer 15 Number of 1 in binary
@Scheduled annotation pit, I stepped on it for you
What is online account opening? In addition, is it safe to open a mobile account?
Copy linked list with random pointer [space for time --hash record]
EB-5 immigration in the United States reappears to be positive, and the reauthorization policy of the regional center is suspended
Machine learning: the concept and application of VC dimension
How to view the CPU cores and threads in win11? Win11 view the tutorial of how many cores and threads the CPU is