Json com.google.code.gson未得到解决

Json com.google.code.gson未得到解决,json,gson,aem,Json,Gson,Aem,我已经在我的项目的pom.xml中包含了google gson依赖项,如下所示: <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.2.2</version> </de

我已经在我的项目的pom.xml中包含了google gson依赖项,如下所示:

        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.2</version>
        </dependency>

com.google.code.gson
格森
2.2.2
我能够构建没有任何问题的项目,但是当我点击URL时,页面不会加载。这是一个CQ5项目,当我访问系统/控制台调试问题时,我发现项目包没有启动。此外,它给出了无法解决的错误com.google.gson,version=[2.2,3]

任何帮助都将不胜感激


谢谢

除了在pom.xml中添加依赖项之外,您还必须将其安装在OSGi容器中。您有两个选项:

1.将JAR包含到您的CQ包中。

在CQ软件包安装期间,将所有JAR放入CQ软件包文件夹
/jcr\u root/apps/APP\u NAME/install
。因此,您可以将GSON库放入此文件夹,并将其添加到OSGi容器中

如果您正在使用assembly plugin创建CQ包,请在程序集描述符中添加以下行:

<dependencySets>
    <dependencySet>
        <outputDirectory>/jcr_root/apps/YOUR_APP/install</outputDirectory>
    </dependencySet>
</dependencySets>

我建议在包项目中配置包插件(在其中配置过滤器)。如中所述:


com.day.jcr.vault
内容包maven插件
格劳普
你的神器
...
...
<Embed-Dependency>gson;scope=runtime</Embed-Dependency>
<plugin>
            <groupId>com.day.jcr.vault</groupId>
            <artifactId>content-package-maven-plugin</artifactId>
            <configuration>

            <embeddeds combine.children="append">
                    <embedded1>
                        <groupId>com.something.grouip</groupId>
                        <artifactId>your-artifact</artifactId>

                    </embedded1>

               </embeddeds>
            </configuration>
...
...
</plugin