如何修复maven项目中pom.xm的错误

时间:2016-01-26 13:51:34

标签: java xml eclipse maven

我应该构建一个Restful FHIR服务器。所以我找到了这个链接Hapi Fhir RestFul Server

我已经在我的本地电脑上下载了源代码,我已经从eclipse中导入它作为Maven Project。所以我对这段代码有些错误。我想,因为找不到一些图书馆。 所以这是我的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>

    <!-- 
    HAPI projects use the HAPI-FHIR base POM as their base. You don't need this
    for your own projects. One thing to note though:  
    -->
    <parent>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir</artifactId>
        <version>1.4-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <groupId>ca.uhn.hapi.fhir</groupId>
    <artifactId>restful-server-example</artifactId>
    <version>1.4-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>HAPI FHIR Sample RESTful Server</name>

    <repositories>
        <repository>
            <id>oss-snapshots</id>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
        </repository>
    </repositories>

    <dependencies>

        <!-- This dependency includes the core HAPI-FHIR classes -->
        <dependency>
            <groupId>ca.uhn.hapi.fhir</groupId>
            <artifactId>hapi-fhir-base</artifactId>
            <version>1.4-SNAPSHOT</version>
        </dependency>
        <!-- At least one "structures" JAR must also be included -->
        <dependency>
            <groupId>ca.uhn.hapi.fhir</groupId>
            <artifactId>hapi-fhir-structures-dstu2</artifactId>
            <version>1.4-SNAPSHOT</version>
        </dependency>

        <!-- This dependency is used for the "FHIR Tester" web app overlay -->
        <dependency>
            <groupId>ca.uhn.hapi.fhir</groupId>
            <artifactId>hapi-fhir-testpage-overlay</artifactId>
            <version>1.4-SNAPSHOT</version>
            <type>war</type>
            <scope>provided</scope>     
        </dependency>
        <dependency>
            <groupId>ca.uhn.hapi.fhir</groupId>
            <artifactId>hapi-fhir-testpage-overlay</artifactId>
            <version>1.4-SNAPSHOT</version>
            <classifier>classes</classifier>
            <scope>provided</scope>     
        </dependency>

        <!-- 
        HAPI-FHIR uses Logback for logging support. The logback library is included 
        automatically by Maven as a part of the hapi-fhir-base dependency, but you 
        also need to include a logging library. Logback is used here, but log4j
        would also be fine. 
        -->
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.1.2</version>
        </dependency>

        <!-- Needed for JEE/Servlet support -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>

        <!-- 
        If you are using HAPI narrative generation, you will need to include Thymeleaf
        as well. Otherwise the following can be omitted.
         -->
        <dependency>
            <groupId>org.thymeleaf</groupId>
            <artifactId>thymeleaf</artifactId>
            <version>2.1.4.RELEASE</version>
        </dependency>

        <!-- Used for CORS support -->
        <dependency>
            <groupId>org.ebaysf.web</groupId>
            <artifactId>cors-filter</artifactId>
            <version>1.0.1</version>
            <exclusions>
                <exclusion>
                    <artifactId>servlet-api</artifactId>
                    <groupId>javax.servlet</groupId>
                </exclusion>
            </exclusions>
        </dependency>


    </dependencies>

    <build>

        <!-- 
        Tells Maven to name the generated WAR file as
        restful-server-example.war
        -->
        <finalName>restful-server-example</finalName>

        <!-- 
        The following is not required for the application to build, but
        allows you to test it by issuing "mvn jetty:run" from the command
        line. 
        -->
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-maven-plugin</artifactId>
                    <version>9.1.1.v20140108</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <!-- 
            Tell Maven which Java source version you want to use
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>

            <!-- 
            The configuration here tells the WAR plugin to include the FHIR Tester
            overlay. You can omit it if you are not using that feature.
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <overlays>
                        <overlay>
                            <groupId>ca.uhn.hapi.fhir</groupId>
                            <artifactId>hapi-fhir-testpage-overlay</artifactId>
                        </overlay>
                    </overlays>
                </configuration>
            </plugin>

            <!-- 
            This plugin is just a part of the HAPI internal build process, you do not
            need to incude it in your own projects
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
                <configuration>
                    <skip>false</skip>
                </configuration>
            </plugin>

        </plugins>
    </build>

</project>

我有像照片

这样的错误

enter image description here

  

EDIT   这是我的错误

Description Resource    Path    Location    Type
AdministrativeGenderEnum cannot be resolved to a variable   PatientResourceProvider.java    /restful-server-example/src/ca/uhn/example/provider line 62 Java Problem
BaseIdentifiableElement cannot be resolved to a type    MyOrganization.java /restful-server-example/src/ca/uhn/example/model    line 97 Java Problem
Bean cannot be resolved to a type   FhirTesterConfig.java   /restful-server-example/src/ca/uhn/example/config   line 38 Java Problem
BooleanDt cannot be resolved to a type  OrganizationResourceProvider.java   /restful-server-example/src/ca/uhn/example/provider line 62 Java Problem
Child cannot be resolved to a type  MyOrganization.java /restful-server-example/src/ca/uhn/example/model    line 36 Java Problem
Child cannot be resolved to a variable  MyOrganization.java /restful-server-example/src/ca/uhn/example/model    line 46 Java Problem
CodeDt cannot be resolved to a type MyOrganization.java /restful-server-example/src/ca/uhn/example/model    line 37 Java Problem
CodeDt cannot be resolved to a type OrganizationResourceProvider.java   /restful-server-example/src/ca/uhn/example/provider line 58 Java Problem
Configuration cannot be resolved to a type  FhirTesterConfig.java   /restful-server-example/src/ca/uhn/example/config   line 20 Java Problem
ContactPointDt cannot be resolved to a type MyOrganization.java /restful-server-example/src/ca/uhn/example/model    line 159    Java Problem
Patient cannot be resolved to a type    PatientResourceProvider.java    /restful-server-example/src/ca/uhn/example/provider line 64 Java Problem

我应该在我的Maven项目中导入哪些库来编译它永远不会错误?

1 个答案:

答案 0 :(得分:0)

您需要将此依赖项添加到您的pom.xml

<dependencies>
 ...
  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>4.1.9.RELEASE</version>
  </dependency>
 ...
</dependencies>

还检查spring和ca.uhn.fhir的版本