之前一直用的是ecplise,换成了idea后导包的操作就发生了变化,这篇文章详细说明下在idea中如何导入jar包
首先在项目根目录建立lib文件夹,把你要导入的jar复制到lib目录下,如果是ecplise直接build path就可以生成路径文件啦,
idea需要你执行如下操作:
打开File-Project Structure-Modules,切换到Dependencies
选取你的lib下面的jar包,导入后点击apply,项目的根目录就会生成.iml文件,这个文件就是记录包及包的位置,以下是我的.iml文件内容
<?xml version="1.0" encoding="UTF-8"?> <module type="JAVA_MODULE" version="4"> <component name="NewModuleRootManager" inherit-compiler-output="true"> <exclude-output /> <content url="file://$MODULE_DIR$"> <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> </content> <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar://$MODULE_DIR$/lib/commons-dbcp-1.4.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar://$MODULE_DIR$/lib/commons-dbutils-1.6.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar://$MODULE_DIR$/lib/commons-pool-1.5.6.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> <root url="jar://$MODULE_DIR$/lib/mysql-connector-java-5.1.37-bin.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> </component> </module>