Maven安装后缺少类

时间:2015-08-27 05:54:39

标签: java maven

所以我几乎一直在撞墙试图解决这个问题......

这是我第一次使用Maven,并在OSX上使用它来安装ews-java-api。

清理或安装后,所有内容都成功构建,但我仍无法通过java文件访问类。

我收到以下错误,

    Connect.java:3: error: package microsoft.exchange.webservices.data does not exist
    import microsoft.exchange.webservices.data.*;
    Connect.java:15: error: cannot find symbol
    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
    ^
    symbol:   class ExchangeService
    location: class Connect

我很好奇我是否总体上在安装路径时出错,安装Maven时...或者如果我在下载A.P.I软件包的地方还有其他问题?

非常感谢任何帮助!!

[编辑] 这是我的bash.profile输出......

    $ cat ~/.bash_profile 
    export M2_HOME=/Users/joliv64/mailtests/apache-maven-3.3.3/
    export PATH=$PATH:$M2_HOME/bin

这也是我的pom.xml文件。

       <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>

<groupId>com.microsoft.ews-java-api</groupId>
<artifactId>ews-java-api</artifactId>

<version>3.0-SNAPSHOT</version>

<name>Exchange Web Services Java API</name>
<description>Exchange Web Services (EWS) Java API</description>

<!-- Required by the site command for certain relative URL configuration. -->
<url>http://www.microsoft.com/</url>

<!-- Used by the javadoc plugin to generate the comments at the bottom. -->
<inceptionYear>2012</inceptionYear>

<!-- Used to define a minimum Maven version. Used in conjunction with plugin
    management to lock in a more current version of the various plugins. -->
<prerequisites>
    <maven>3.1.0</maven>
</prerequisites>

<organization>
    <name>Microsoft</name>
    <url>http://www.microsoft.com/</url>
</organization>

<properties>
    <!-- Eliminates the file encoding warning. Of course, all of your files
        should probably be UTF-8 nowadays. -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <javaLanguage.version>1.6</javaLanguage.version>
    <javadoc.doclint.param/>

    <!--  Dependencies [BUILD]:  -->
    <maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
    <maven-javadoc-plugin.version>2.10.3</maven-javadoc-plugin.version>
    <maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
    <nexus-staging-maven-plugin.version>1.6.5</nexus-staging-maven-plugin.version>
    <maven-source-plugin.version>2.4</maven-source-plugin.version>
    <animal-sniffer-maven-plugin.version>1.14</animal-sniffer-maven-plugin.version>
    <animal-sniffer-maven-plugin.signature.version>1.1</animal-sniffer-maven-plugin.signature.version>
    <!--  Dependencies [REPORT]:  -->
    <maven-site-plugin.version>3.4</maven-site-plugin.version>
    <maven-project-info-reports-plugin.version>2.8</maven-project-info-reports-plugin.version>
    <versions-maven-plugin.version>2.2</versions-maven-plugin.version>
    <maven-jxr-plugin.version>2.5</maven-jxr-plugin.version>
    <maven-surefire-report-plugin.version>2.18.1</maven-surefire-report-plugin.version>
    <!--  Dependencies [COMPILE]:  -->
    <httpclient.version>4.4.1</httpclient.version>
    <httpcore.version>4.4.1</httpcore.version>
    <commons-logging.version>1.2</commons-logging.version>
    <joda-time.version>2.8</joda-time.version>
    <commons-lang3.version>3.4</commons-lang3.version>
    <!--  Dependencies [TEST]:  -->
    <junit.version>4.12</junit.version>
    <hamcrest-all.version>1.3</hamcrest-all.version>
    <mockito-core.version>1.10.19</mockito-core.version>
    <slf4j.version>1.7.12</slf4j.version>
    <logback.version>1.1.3</logback.version>
</properties>

<profiles>
    <profile>
        <!-- handle broken builds on jdk1.8 due to doclint function -->
        <id>default-jdk18-profile</id>
        <activation>
            <jdk>[1.8,)</jdk>
        </activation>
        <properties>
            <javadoc.doclint.param>-Xdoclint:none</javadoc.doclint.param>
        </properties>
    </profile>
    <profile>
        <id>release-sign-artifacts</id>
        <activation>
            <property>
                <name>gpg.passphrase</name>
            </property>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>${maven-gpg-plugin.version}</version>
                    <executions>
                        <execution>
                            <id>sign-artifacts</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>sign</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

<licenses>
    <license>
        <name>MIT License</name>
        <url>http://opensource.org/licenses/MIT</url>
        <distribution>repo</distribution>
    </license>
</licenses>

<issueManagement>
    <url>https://github.com/OfficeDev/ews-java-api/issues</url>
    <system>GitHub Issues</system>
</issueManagement>

<ciManagement>
    <system>travis</system>
    <url>https://travis-ci.org/OfficeDev/ews-java-api</url>
</ciManagement>

<scm>
    <url>https://github.com/OfficeDev/ews-java-api</url>
    <connection>scm:git:ssh://git@github.com:OfficeDev/ews-java-api.git</connection>
    <developerConnection>scm:git:ssh://git@github.com:OfficeDev/ews-java-api.git</developerConnection>
</scm>

<distributionManagement>
    <snapshotRepository>
        <id>ossrh-snapshot</id>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
        <id>ossrh</id>
        <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>

    </repository>
</distributionManagement>

<dependencies>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>${httpclient.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpcore</artifactId>
        <version>${httpcore.version}</version>
    </dependency>

    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>${commons-logging.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>${commons-lang3.version}</version>
    </dependency>

    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>${joda-time.version}</version>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-all</artifactId>
        <version>${hamcrest-all.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-core</artifactId>
        <version>${mockito-core.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${slf4j.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>${logback.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>${slf4j.version}</version>
        <scope>test</scope>
    </dependency>

<!-- Added Dependency -->
<dependency>
        <groupId>com.microsoft.ews-java-api</groupId>
        <artifactId>ews-java-api</artifactId>
        <version>2.0-SNAPSHOT</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <!-- Deployment / build plugins -->
        <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <version>${nexus-staging-maven-plugin.version}</version>
            <extensions>true</extensions>
            <configuration>
                <!-- Ref.: http://books.sonatype.com/nexus-book/reference/staging-deployment.html -->
                <autoReleaseAfterClose>true</autoReleaseAfterClose>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven-compiler-plugin.version}</version>
            <configuration>
                <encoding>${project.build.sourceEncoding}</encoding>
                <source>${javaLanguage.version}</source>
                <target>${javaLanguage.version}</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>${maven-javadoc-plugin.version}</version>
            <configuration>
                <linksource>true</linksource>
                <additionalparam>${javadoc.doclint.param}</additionalparam>
            </configuration>
            <executions>
                <execution>
                    <id>attach-javadocs</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>${maven-source-plugin.version}</version>
            <executions>
                <execution>
                    <id>attach-sources</id>
                    <goals>
                        <goal>jar-no-fork</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>animal-sniffer-maven-plugin</artifactId>
            <version>${animal-sniffer-maven-plugin.version}</version>
            <configuration>
                <signature>
                    <groupId>org.codehaus.mojo.signature</groupId>
                    <artifactId>java16-sun</artifactId>
                    <version>${animal-sniffer-maven-plugin.signature.version}</version>
                </signature>
            </configuration>
            <executions>
                <execution>
                    <id>check-java16-sun</id>
                    <phase>test</phase>
                    <goals>
                        <goal>check</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <!-- Deployment / build plugins END -->
    </plugins>
    <!-- Used to bump all of the various core plugins up to Maven current.
        Use this in conjunction with the versions-maven-plugin to keep your Maven
        plugins up to date. -->
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>${maven-site-plugin.version}</version>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

<reporting>
    <plugins>
        <!-- Basic report generation. -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-project-info-reports-plugin</artifactId>
            <version>${maven-project-info-reports-plugin.version}</version>
        </plugin>

        <!-- Dependency version reporting. Relies on standard version numbering
            - you should use standard version numbering too!
            http://mojo.codehaus.org/versions-maven-plugin/version-rules.html -->
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>versions-maven-plugin</artifactId>
            <version>${versions-maven-plugin.version}</version>
            <reportSets>
                <reportSet>
                    <reports>
                        <report>dependency-updates-report</report>
                        <report>plugin-updates-report</report>
                        <report>property-updates-report</report>
                    </reports>
                </reportSet>
            </reportSets>
        </plugin>

        <!-- Generates the Javadoc for the report. -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>${maven-javadoc-plugin.version}</version>
            <configuration>
                <linksource>true</linksource>
                <additionalparam>${javadoc.doclint.param}</additionalparam>
            </configuration>
        </plugin>

        <!-- Generates a nice HTML linked source cross-reference. -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jxr-plugin</artifactId>
            <version>${maven-jxr-plugin.version}</version>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <version>${maven-surefire-report-plugin.version}</version>
        </plugin>
    </plugins>
</reporting>
      <repositories>
<repository>
  <id>sonatype-snapshots</id>
  <name>Sonatype OSS Snapshots</name>
  <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
  <releases>
    <enabled>false</enabled>
  </releases>
  <snapshots>
    <enabled>true</enabled>
  </snapshots>
</repository>

1 个答案:

答案 0 :(得分:0)

因此问题的解决方案比预期的要简单得多。

我用javac编译我的文件,并没有将我的类放入一个用mvn编译的包中。

此外,进口还有一点点因为它们不像某些源代码所宣传的那样。所以当然mvn正确构建,我只是试图以不正确的方式访问类。

感谢您的帮助!

相关问题