迁移到 AEM 6.3 后缺少 AEM servlet 配置工厂

AEM servlet configuration factory missing after moving to AEM 6.3

我将 ACS commons 分叉用于 AEM 6.0,但在 6.3 中 /system/console/configMgr 中缺少工厂。我将代码与当前的 ACS 站点地图进行了比较,注释是相同的。

@Component(metatype = true,  
        label = "Apple SEO Site Map Servlet",  
        description = "SEO Site Map Servlet",  
        configurationFactory = true,  
        policy = ConfigurationPolicy.REQUIRE)  
@Service  
@SuppressWarnings("serial")  
@Properties({@Property(name = "sling.servlet.resourceTypes", unbounded = PropertyUnbounded.ARRAY,  
        label = "Sling Resource Type", description = "Sling Resource Type for the Home Page component or components."),  
        @Property(name = "sling.servlet.selectors", value = "search-engine-sitemap", propertyPrivate = true),  
        @Property(name = "sling.servlet.extensions", value = "xml", propertyPrivate = true),  
        @Property(name = "sling.servlet.methods", value = "GET", propertyPrivate = true),  
        @Property(name = "webconsole.configurationFactory.nameHint",  
                value = "Site Map on resource types: [{sling.servlet.resourceTypes}]")})

根据以上评论中的讨论,问题在于设置 maven 插件以生成 scr 描述符,而不是注释本身的使用。

关于这些注释如何工作的一些附加信息:

  • 注释实际上是在创建包以生成 xml 文件时处理的。它是在 OSGI 容器中使用的生成的 XML 输出。如果你有理由相信你使用的注释是正确的,那么验证已经生成的xml。

  • 在 AEM 6.3 之前,一般做法是使用带 maven-scr-plugin 的 felix scr 注释。从 6.3 开始,您可以使用来自官方 OSGI 包的注释,这是在 R6 中添加的,因此 felix 注释已被弃用。您不再需要 maven-scr-plugin,maven-bundle-plugin 将处理 OSGI R6 注释。

  • 因为容器使用的是 xml,所以 <6.3 的服务声明没有理由在 6.3 上停止工作。如果有问题,通常是在构建设置中。

  • 可以在工作区的以下位置找到生成的 scr 描述 target/classes/OSGI-INF & target/classes/META-INF。

  • 如果您使用 OSGI R6 注释和 maven-bundle-plugin 并且看不到生成的 xml 文件,请将 <exportScr>true</exportScr> 添加到插件配置的配置部分聚甲醛。 Adobe 原型生成的 POM 从版本 12

  • 开始跳过此设置