java - 为什么我不能在我的 Eclipse Maven 项目中将一个类导入到我的 java 文件中?
问题描述
我在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>
推荐阅读
- python-3.x - 我是 python 新手,我正在尝试构建一个简单的井字游戏。当我从用户那里获取输入时,它会进入无限循环
- javascript - 使用 sequelize 从两个模型表中获取数据
- c++ - 如何从键盘调用枚举器?
- maven - spring boot Maven打包时如何修改配置文件名,如config.xml xml。重新配置。XML
- python - Easy Leetcode:BST 深度优先搜索存在堆栈溢出错误
- node.js - 在 Linux 终端中看不到 console.log()
- html - 右侧打开的 CSS 嵌套下拉菜单
- typescript - 如何在函数上使用泛型类型,该类型必须满足某些条件?
- javascript - 将 Apollo Client 与 NextJS 一起使用时服务器端渲染数据?
- python - Modified War Card Game - 如何跑10,000手,记录每场比赛的获胜者,