Element 'dependency' cannot have character (children), because this type's content type is element-

今天项目里需要用到fastjson,就从http://search.maven.org找了一下,顺手复制了

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>1.2.47</version>
</dependency>

结果更新maven后,该dependency报错:

 Element 'dependency' cannot have character (children), because this type's content type is element-only.

很是奇怪,显示检查是否没有放在

<dependencies>...</dependencies>

发现没问题,而且单独的这个<dependency>看起来没任何问题,后来在StackOverflow上发现了答案(原帖路径:https://stackoverflow.com/questions/7835389/problems-using-spring-hibernate/7835746#7835746),解决办法是:

在pom.xml中,Ctrl + Shift + F,会看到原来

<dependency>
    <groupId>com.alibaba</groupId>

    <artifactId>fastjson</artifactId>

    <version>1.2.47</version>
</dependency>

中间是有内容的,就是这些看似像空行的东西导致了错误,删除这些,留下<groupId>、<artifactId>、<version>,问题就解决了。



猜你喜欢

转载自blog.csdn.net/yangfengjueqi/article/details/80004126