当前位置:网站首页>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 ;
边栏推荐
- solo 博客皮肤导入 skins 文件夹后出现 500 错误
- Getting started with qpainter: drawing the chess interface
- Solr basic operation 8
- How to write controller layer code gracefully?
- Solr basic operation 10
- 8软件工程环境
- 爬虫入门实战:斗鱼弹幕数据抓取,附送11节入门笔记
- Leetcode (76) -- Minimum Covering substring
- Is China Merchants Securities reliable? Is it safe to open a stock account?
- Embedded development: Hardware in the loop testing
猜你喜欢

Sword finger offer 15 Number of 1 in binary

6.29 problem solving

QT learning 02 GUI program example analysis

Applet plug-in access, development and precautions

Some specifications based on zfoo development project

After 8 years of polishing, "dream factory of game design" released an epic update!

Construction of module 5 of actual combat Battalion

What is IGMP? What is the difference between IGMP and ICMP?

架构实战营模块5作业

HPE launched ARM CPU general server product
随机推荐
Golang6 reflection
數莓派 4怎麼樣?可能的玩法有哪些?
Exploration and Practice on the future direction of byte cloud database
Matlab exercises -- program control process exercise
Solr基础操作11
6.28 problem solving
Mysql:sql overview and database system introduction | dark horse programmer
How to write controller layer code gracefully?
Web APIs 环境对象 丨黑马程序员
Applet plug-in access, development and precautions
Binary search tree 230 The element with the smallest K in the binary search tree 1038 From binary search tree to larger sum tree
Solr basic operation 11
shell-运算符
Activity invitation | the Apache Doris community essay and speech solicitation activity has begun!
QT learning 05 introduction to QT creator project
复制带随机指针的链表[空间换时间--hash记录]
Basic operations such as MySQL startup under Windows platform
Zhongang Mining: Fluorite helps the construction and development of lithium battery in fluorine industry
Cacti maximum monitoring number test
Ingenious application of golang generics to prevent null pointer errors of variables and structural fields