1

我在我的项目lib目录下添加了opencsv的jar。
然后,在intelliJ下Project Structure->Libraries添加了jar。

但是,不知何故,intelliJ 无法识别它。
这是为什么?

4

2 回答 2

3

Don't go this way, create a maven project and it will solve many problems you haven't encountered yet :).

  1. Open up you intelliJ Idea
  2. select 'File' -> 'New Project' 'Create project from scratch' -> 'Next'
  3. Enter the project title, select 'Maven Module' -> 'Next'
  4. Click 'Finish' Replace the generated pom.xml with the following:

    http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0

    <groupId>opencsvtst</groupId>
    <artifactId>opencsvtst</artifactId>
    <version>1.0</version>
    
    <dependencies>
        <dependency>
            <groupId>net.sf.opencsv</groupId>
            <artifactId>opencsv</artifactId>
            <version>2.0</version>
        </dependency>
    </dependencies>
    

  5. Under src/main/java add your classes (the one with the main method probably) and use the opencsv library.

You will find the compiled jar within the target folder once you build the project.

于 2012-10-11T13:28:55.283 回答
2

项目结构”对话框中的表示可以配置一次然后在多个项目和模块中使用的全局库。要使库可用于模块,请将其添加到模块依赖项中。

于 2012-10-12T10:51:24.663 回答