我有以下服务类:
@Component(immediate = true)
@Service
public class Myclass implements MyInterface
{
@Override
public String doIt()
{
return "This is default bean";
}
}
在pom文件中我有:
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
<version>1.9.6</version>
<scope>provided</scope>
</dependency>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<_include>
-target/classes/META-INF/beans.bnd
</_include>
<Export-Package></Export-Package>
<Private-Package>com.company.temp.*</Private-Package>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
<version>1.21.0</version>
<executions>
<execution>
<id>generate-scr-scrdescriptor</id>
<goals>
<goal>scr</goal>
</goals>
</execution>
</executions>
</plugin>
...
<plugins>
</build>
问题是没有生成DS的xml文件。此外,清单文件中没有Service-Component行。我的错误在哪里(PS java8)?
答案 0 :(得分:1)
如果您打算使用标准DS注释(而不是felix注释)。然后只需使用下面的配置。
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.5.4</version>
<extensions>true</extensions>
<configuration>
<instructions>
<_dsannotations>*</_dsannotations>
</instructions>
</configuration>
</plugin>
如果您需要一个完整的示例,我也有一个DS tutorial。