In the Java Web project, the inevitable use of the database, the following is the idea of adding MySQL dependency method.
If you see this, it means you understand idea,maven and Tomcat, so ...
Just add the dependencies in the Pom.xml, and here's my config file.
<?XML version= "1.0" encoding= "UTF-8"?><Projectxmlns= "http://maven.apache.org/POM/4.0.0"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupId>Com.suixue</groupId> <Artifactid>Example</Artifactid> <version>1.0-snapshot</version> <Dependencies> <Dependency> <!--JUnit 4.7 - <groupId>Junit</groupId> <Artifactid>Junit</Artifactid> <version>4.11</version> <type>Jar</type> <Scope>Test</Scope> </Dependency> <Dependency> <!--Spring 3.2 - <groupId>Org.springframework</groupId> <Artifactid>Spring-context</Artifactid> <version>4.1.6.RELEASE</version> <type>Jar</type> </Dependency> <Dependency> <groupId>Log4j</groupId> <Artifactid>Log4j</Artifactid> <version>1.2.17</version> <type>Jar</type> </Dependency> <Dependency> <!--Jackson Core Pack - <groupId>Com.fasterxml.jackson.core</groupId> <Artifactid>Jackson-core</Artifactid> <version>2.2.1</version> </Dependency> <Dependency> <!--Jackson Data Binding package - <groupId>Com.fasterxml.jackson.core</groupId> <Artifactid>Jackson-databind</Artifactid> <version>2.1.3</version> </Dependency> <Dependency> <!--Jackson Note Pack - <groupId>Com.fasterxml.jackson.core</groupId> <Artifactid>Jackson-annotations</Artifactid> <version>2.1.2</version> </Dependency> <dependency> <groupId>mysql</groupId> <artifactid>mysql-connector-java& lt;/artifactid> <version>5.1.25</version> </dependency> </Dependencies></Project>
The red area is the code that adds the MySQL dependency, and if the version is different, you can change it again in versions.
After adding the dependency, idea will automatically download the required jar package for us!
Idea in Maven managed to add MySQL dependency