为什么不能将类导入到Eclipse Maven Project中的java文件中?

时间:2019-06-15 19:23:48

标签: java spring eclipse maven import

我在Maven Repository上发现了以下内容:

<!-- https://mvnrepository.com/artifact/org.springframework.xd/spring-xd-dirt -->
<dependency>
    <groupId>org.springframework.xd</groupId>
    <artifactId>spring-xd-dirt</artifactId>
    <version>1.0.4.RELEASE</version>
</dependency>

Maven存储库提供的主页将我带到this java file

这里是:

/*
 * Copyright 2015 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.xd.dirt.web.controller.support;

/**
 *
 * @author Gunnar Hillert
 *
 */
public class AuthenticationRequest {

    private String username;

    private String password;

    public AuthenticationRequest() {
    }

    public AuthenticationRequest(String username, String password) {
        this.username = username;
        this.password = password;
    }

    /**
     * @return the username
     */
    public String getUsername() {
        return username;
    }

    /**
     * @param username the username to set
     */
    public void setUsername(String username) {
        this.username = username;
    }

    /**
     * @return the password
     */
    public String getPassword() {
        return password;
    }

    /**
     * @param password the password to set
     */
    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return "AuthenticationRequest [username=" + username + ", password=" + password + "]";
    }


}

该页面告诉我AuthenticationRequest可以使用

导入
import org.springframework.xd.dirt.web.controller.support.AuthenticationRequest;

我在pom.xml中收到一条错误消息,指出缺少工件。我认为该库依赖于另一个库。我将工件放入pom.xml中,该错误已解决。

但是我的导入语句仍然出现错误,说:

  

导入org.springframework.xd.dirt.web.controller.support不能为    解决

我想念什么?如何导入AuthenticationRequest类?

1 个答案:

答案 0 :(得分:0)

我进行了一些搜索,发现需要在pom.xml中添加以下内容:

    <dependency>
        <groupId>org.springframework.xd</groupId>
        <artifactId>spring-xd-dirt</artifactId>
        <!-- <version>1.0.4.RELEASE</version> -->
        <version>1.3.1.RELEASE</version>
        <!-- <scope>compile</scope> -->
    </dependency>

    <repository>
        <id>spring-repo</id>
        <url>https://repo.spring.io/release</url>
    </repository>