![](/img/trans.png)
[英]Why am I not able to import a class into java file in Eclipse Maven Project?
[英]Why can't I import a class into my java file in my Eclipse Maven Project?
我在Maven資源庫中找到了以下內容:
<!-- 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 Repository提供的主頁引導我訪問這個java文件 。
這里是:
/*
* 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?
我做了一些搜索並想出我需要在我的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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.