search

Home  >  Q&A  >  body text

java - idea 创建了maven的项目,pom.xml中添加了mybatis依赖了,但是代码中找不都?

pom.xml

代码中写找不到类:

为什么呢??

**

加粗文字**

巴扎黑巴扎黑2769 days ago919

reply all(6)I'll reply

  • 高洛峰

    高洛峰2017-04-18 10:19:16

    inTerminal中手动运行mvn clean install.
    If the operation is successful, you can refresh the project.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 10:19:16

    pom.xml has two errors

    1. The dependency of mybatis does not end with </dependency>;

    2. All children of dependency应该是<dependencies></dependencies>;

    As long as there are no errors in pom.xml and the warehouse address configured in settings.xml can be connected successfully, just execute maven > reimport in the IDE and the jar package will be downloaded to the local warehouse.

    But there is one situation that you should pay attention to: sometimes the download may be interrupted halfway, and then re-download will not be able to download again because of the damaged jar package downloaded before. At this time, usually go to the local warehouse path and manually download the previously downloaded Just remove the jar package.

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-18 10:19:16

    Is the package path of

    ctrl+alt+shift+s, 在弹出的面板里面看选择Libraries,看一下有没有mybatis的jar包,如果没有的话就是没下好,执行一下reimport试试。
    否则的话看一下你源码中有没有import,或者import right or wrong? I think this is more likely... After all, the custom classes in the code cannot be found. . .
    If there is no problem with the above... Re-import this project, this is a universal solution. .

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-18 10:19:16

    reply
    0
  • 怪我咯

    怪我咯2017-04-18 10:19:16

    Is it possible to write a dependency and a denpendency in your pom?

    Do you have import org.apache.ibatis.session.SqlSessionFactory in your java file?

    Click on External Libraries and look for
    Maven:org.mybatis:mybatis:version number

    reply
    0
  • 黄舟

    黄舟2017-04-18 10:19:16

    Right-click on pom.xml and report again. If the speed is slow, it is recommended to directly download the jar and put it into your maven library

    reply
    0
  • Cancelreply