Maven:包不存在+找不到符号

时间:2016-06-27 08:04:48

标签: maven apache-felix

我知道这个问题已被问过很多,但我发现没有答案与我的情况相关或适用。

我有很多具有以下文件夹结构的项目:

main
+-- pom.xml
+-- shared
    +--- pom.xml
    +--- org.apache.felix
      +---- pom.xml
    +--- com.google.protobuf
      +---- pom.xml
    +--- project1 
      +---- pom.xml
    +--- project2
      +---- pom.xml
    +--- project3
      +---- pom.xml
    +--- ...

基本上一些jar项目帮助其他人使用源文件。我正在努力编译所有内容。该过程编译jar项目,但在project1中出现以下错误:

package org.apache.felix.service.command does not exist

cannot find symbol [ERROR] symbol:   class activator
由于第一个错误,预计后者是后者。我相信某处有一些引用错误。我正在分享我的以下pom.xml文件:

org.apache.felix的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <parent>
      <groupId>shared</groupId>
      <artifactId>shared.master</artifactId>
      <relativePath>../pom.xml</relativePath>
      <version>1.0.0-SNAPSHOT</version>
   </parent>
   <groupId>shared</groupId>
   <artifactId>org.apache.felix</artifactId>
   <name>org.apache.felix</name>
   <version>1.0.0</version>
</project>

project1 的pom.xml,它会抛出错误

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <parent>
      <groupId>shared</groupId>
      <artifactId>shared.master</artifactId>
      <relativePath>../pom.xml</relativePath>
      <version>1.0.0-SNAPSHOT</version>
   </parent>
   <groupId>shared</groupId>
   <artifactId>shared.cmd.felix</artifactId>
   <name>shared.cmd.felix</name>
   <version>1.0.0</version>
   <packaging>jar</packaging>
   <dependencies>
      <dependency>
         <groupId>shared</groupId>
         <artifactId>org.apache.felix</artifactId>
         <version>1.0.0</version>
         <scope>system</scope>
         <systemPath>${project.basedir}/../org.apache.felix/felix.jar</systemPath>
      </dependency>
      <dependency>
         <groupId>shared</groupId>
         <artifactId>org.apache.log4j</artifactId>
         <version>1.0.0</version>
         <scope>system</scope>
         <systemPath>${project.basedir}/../org.apache.log4j/log4j-1.2.17.jar</systemPath>
      </dependency>
   </dependencies>
   <build>
      <sourceDirectory>src/</sourceDirectory>
      <plugins>
         <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
               <source>${jdk.version}</source>
               <target>${jdk.version}</target>
            </configuration>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.1</version>
            <configuration>
               <archive>
                  <manifest>
                     <addClasspath>true</addClasspath>
                     <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                     <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                  </manifest>
                  <manifestEntries>
                     <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                     <Bundle-Version>${project.version}</Bundle-Version>
                     <Bundle-ClassPath>.</Bundle-ClassPath>
                     <Export-Package>shared.cmd.felix</Export-Package>
                  </manifestEntries>
               </archive>
            </configuration>
         </plugin>
      </plugins>
   </build>
</project>

这是project1 的M ANIFEST.MF文件:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: project1
Bundle-SymbolicName: project1
Bundle-Version: 1.0.0
Fragment-Host: shared.mw;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ClassPath: .,
 bundle/system/org.apache.felix.gogo.runtime-0.10.0.jar
Export-Package: shared.cmd.ext
Import-Package: shared,
 shared.cmd,
 shared.comp,
 shared.mw,
 shared.sched,
 shared.service,
 org.apache.felix.service.command,
 org.apache.log4j,
 org.osgi.framework
Require-Bundle: org.apache.felix;bundle-version="1.0.0",
 org.apache.activemq

顺便说一句,我从/shared目录运行脚本,而不是/main

任何人都遇到类似的情况?

0 个答案:

没有答案