How can I resolve these AWS imports?

放肆的年华 提交于 2019-12-13 18:11:36

问题


In my pom.xml I have this:

<instructions>
    <Embed-Transitive>true</Embed-Transitive>
    <Export-Package>
        com.amazonaws.HttpMethod,
        com.amazonaws.services.s3.*
    </Export-Package>
    <Embed-Dependency>
        gson,
        aws-java-sdk,
        jackson-core
    </Embed-Dependency>
    ...

And as dependencies I have these:

<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-s3</artifactId>
    <version>1.11.115</version>
</dependency>

<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-core</artifactId>
    <version>1.11.115</version>
</dependency>

When I build my .jar with mvn clean install and upload it to AEM I see this:

What are all these "extra" packages in red that it can't resolve, and how can I resolve them?

How can I prevent this from happening BEFORE I build and upload a package to AEM?


回答1:


The packages in red are packages you've imported in you're classes with java import. the dependencies from which those imports come from need to be embedded in your pom in that <Embed-Dependency>. Alternatively, You can install an AEM bundle that exports those packages in order for your bundle imports to be resolved.




回答2:


When I build my .jar with mvn clean install and upload it to AEM

This is not the normal way for building AEM projects, i.e. you normally don't upload just *.jar files to your AEM instance. In short, you create an OSGi bundle that needs to be installed to your AEM instance. This bundle (if compiled/built correctly) should contain all your code and it's dependencies in a nice little zip file which should solve the dependencies issues.

Alternatively, if you just want to upload *.jar files then you will need to find the dependencies and upload them as individual jar files or follow this tutorial to convert one or many jar files into an OSGi bundle and upload to your AEM instance. This is a common practice for many 3rd party proprietary libs but S3 libs are easily available so probably not the best option for it (unless you have a business case).

Ideally, your AEM project's POM should have all the AWS S3 dependencies in it and package it with your OSGi bundles so that other dependencies within your organisation are also managed in standard AEM way.

If you are using Eclipse or similar IDE then you can read this tutorial.



来源:https://stackoverflow.com/questions/43242977/how-can-i-resolve-these-aws-imports

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!