【发布时间】:2015-10-02 11:04:35
【问题描述】:
我正在使用https://eclipse.adobe.com/aem/dev-tools/ 创建一个项目。创建后,我在 Eclipse 中具有以下结构:
我希望能够在我的组件中使用 GoogleMaps API。所以我在hometest.core/pom.xml中添加了它的依赖项
<dependency>
<groupId>com.google.maps</groupId>
<artifactId>google-maps-services</artifactId>
<version>0.1.7</version>
<scope>compile</scope>
</dependency>
我还在hometest.core/pom.xml_exportcontents 中添加了所有内容
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Directory>OSGI-INF/lib</Embed-Directory>
<_exportcontents>
*
</_exportcontents>
</instructions>
</configuration>
</plugin>
然后我将com.google.maps.model.GeocodingResult导入HelloServiceProxy.java,如下图:
我使用 mvn clean install -PautoInstallPackage 将包安装到 aem 的本地实例
但是,当我尝试将组件添加到页面时,我收到以下错误:
java.lang.Error: Unresolved compiler problem: Only a type can be 进口的。 com.google.maps.model.GeocodingResult 解析为一个包
以下是错误截图:
更新 1
我从另一个全新的 AEM 项目开始,做了以下事情:
-
在 core/pom.xml 中添加了
maven-bundle-plugin的配置设置,如下所示<plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <configuration> <instructions> <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency> <Embed-Directory>OSGI-INF/lib</Embed-Directory> <_exportcontents> * </_exportcontents> </instructions> </configuration> </plugin> -
像这样添加了谷歌地图依赖:
<dependency> <groupId>com.google.maps</groupId> <artifactId>google-maps-services</artifactId> <version>0.1.7</version> <scope>compile</scope> </dependency> 使用此
mvn clean install -PautoInstallPackage进行部署
当我尝试向页面添加组件时出现错误:
java.lang.Error: Unresolved compilation problems:
Only a type can be imported. com.google.maps.model.GeocodingResult resolves to a package
Only a type can be imported. org.demo.anothertest.core.HelloService resolves to a package
HelloService cannot be resolved to a type
HelloService cannot be resolved to a type
【问题讨论】:
-
我以前见过这个问题。有时,强制重新编译视图或 ui 的表面更改会有所帮助。我对它不是很了解。但可能是核心和ui包中的依赖项试图使用ui jsp编译时未注册的服务
-
@ChristopherRockwell 你是怎么解决的?
-
您可能对我最近发布的stackoverflow.com/questions/31191299/google-client-api-in-osgi 的问题感兴趣,但我没有导出罐子,只是嵌入。所以它们只能在服务/核心包中使用。 .... 另外关于“只能导入一个类型”。我之前通过仅重新部署视图“解决”了这个问题,在另一种情况下,只是在 JSP 中保存了一个空白更改(强制重新编译)。但如果是我,我会嵌入(而不是导出)罐子,并尽可能在同一个包中使用它们,即使这不是真正的 osgi 方式
-
你能解决这个问题吗?
标签: java maven osgi aem aem-developer-tools