content
Several common problems with Maven
Set the directory in Maven to the corresponding color
maven garbled problem at runtime
maven toolbar not found problem
Import jar package using coordinates
Import the required dependencies:
There is a compatibility problem with versions above maven 3.6.2 in idea. In order to avoid conflicts, version 3.6.1 is installed in idea
Create an empty project, name it, and then search for maven in the settings
Several common problems with Maven
Set the directory in Maven to the corresponding color
Add the following:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
The refresh is done as follows:
maven garbled problem at runtime
Add the following:
-Dfile.encoding=GB2312
operation result:
maven toolbar not found problem
Shortcut settings
Clicking compile will generate the corresponding target directory, and clicking clean will clear the target directory
Create maven with archetype
create web
import maven project
The + sign of the maven tool, select the maven pom.xml file you want to import
If maven is not displayed
Add plugin quick action
Open the settings as follows
Import jar package using coordinates
1. Write the <dependencies> tag in pom.xml (you can also import it manually with alt+insert)
2. Use <dependency> to introduce coordinates in the <dependencies> tag
3. Define the groupId, artfigactId, version of the coordinates
4. Click the refresh button to make the coordinates take effect
Import the required dependencies:
<!-- <dependencies> 导入依赖</dependencies>-->
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!--导入mysql的jar包,只要写出坐标位置即可-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
</dependency>
</dependencies>
Dependency scope
By setting the dependency scope of the coordinates, you can set the scope of the corresponding jar package: compilation environment, test environment, running environment
<scope> The default value text is: compile (that is, it takes effect everywhere)
For example, <scope>test</scope> is only valid in the test directory, the rest are invalid