我想使用Maven将spark-connector-cassandra添加到我的Java项目中。当我添加依赖项时,maven无法识别版本(将其标记为红色)。为什么?我还添加了spark依赖关系,但是有了这种依赖关系就没有问题。 这是我的pom文件。
C:\Users\Utente>mvn dependency:resolve
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256M; support was removed in 8.0
[INFO] Scanning for projects...
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-clean-plugin:2.5: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-deploy-plugin/2.7/maven-deploy-plugin-2.7.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-deploy-plugin:2.7: Plugin org.apache.maven.plugins:maven-deploy-plugin:2.7 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-deploy-plugin:jar:2.7
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-site-plugin/3.3/maven-site-plugin-3.3.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-site-plugin:3.3: Plugin org.apache.maven.plugins:maven-site-plugin:3.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-site-plugin:jar:3.3
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-antrun-plugin/1.3/maven-antrun-plugin-1.3.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-antrun-plugin:1.3: Plugin org.apache.maven.plugins:maven-antrun-plugin:1.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-antrun-plugin:jar:1.3
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-5/maven-assembly-plugin-2.2-beta-5.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5: Plugin org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-assembly-plugin:jar:2.2-beta-5
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.8/maven-dependency-plugin-2.8.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-dependency-plugin:2.8: Plugin org.apache.maven.plugins:maven-dependency-plugin:2.8 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-dependency-plugin:jar:2.8
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-release-plugin/2.3.2/maven-release-plugin-2.3.2.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-release-plugin:2.3.2: Plugin org.apache.maven.plugins:maven-release-plugin:2.3.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-release-plugin:jar:2.3.2
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml
[WARNING] Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml from/to central (http://repo.maven.apache.org/maven2): Connect to 10.0.3.69:3128 [/10.0.3.69] failed: Connection timed out: connect
[WARNING] Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from/to central (http://repo.maven.apache.org/maven2): Connect to 10.0.3.69:3128 [/10.0.3.69] failed: Connection timed out: connect
[WARNING] Failure to transfer org.apache.maven.plugins/maven-metadata.xml from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml from/to central (http://repo.maven.apache.org/maven2): Connect to 10.0.3.69:3128 [/10.0.3.69] failed: Connection timed out: connect
[WARNING] Failure to transfer org.codehaus.mojo/maven-metadata.xml from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from/to central (http://repo.maven.apache.org/maven2): Connect to 10.0.3.69:3128 [/10.0.3.69] failed: Connection timed out: connect
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:50 min
[INFO] Finished at: 2018-08-17T11:54:53+01:00
[INFO] Final Memory: 7M/123M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'dependency' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\Utente\.m2\repository), central (http://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException
粗体字是问题所在。我该如何解决该问题?谢谢 ;) 我厌倦了运行mvn依赖项:解决,但这就是结果
public class InsertEventListenerImpl extends AbstractUserHistory
implements PostInsertEventListener {
@Override
public void onPostInsert(PostInsertEvent postInsertEvent) {
EventSource session = postInsertEvent.getSession();
Object currentObject = postInsertEvent.getEntity();
Object[] currentState = postInsertEvent.getState();
String[] propertyNames = postInsertEvent.getPersister().getPropertyNames();
if(currentObject instanceof UserCredentialsEntity){
insertUserCredential(currentState, propertyNames, session);
}else if(currentObject instanceof PlainUserEntity){
insertPlainUser(currentObject, currentState, propertyNames, session);
}else if(currentObject instanceof Employment){
updateEmployment(currentState, propertyNames, session);
}
}
private void insertPlainUser(Object currentObject, Object[] currentState, String[] propertyNames, EventSource session){
PlainUserEntity plainUserEntity = (PlainUserEntity) currentObject;
final Session localSession = getNewSession(session);
final Transaction tx = localSession.beginTransaction();
for(int i = 0; i < propertyNames.length; i++){
if(isNotNull(currentState[i]) && !(currentState[i] instanceof List)){
UserHistory userHistory = createUserHistory(plainUserEntity, propertyNames[i].toString(), currentState[i].toString());
session.persist(userHistory);
}
}
tx.commit();
}
public abstract class AbstractUserHistory {
public UserHistory createUserHistory(PlainUserEntity plainUserEntity, String variableName, String newValue){
UserHistory userHistory = new UserHistory();
userHistory.setVariableName(variableName);
userHistory.setNewValue(newValue);
userHistory.setUpdateDate(Calendar.getInstance());
// userHistory.setPlainUserEntity(plainUserEntity);
return userHistory;
}
答案 0 :(得分:0)
尝试运行mvn dependency:resolve
,看看会发生什么。
你说
行家无法识别版本(将其标记为红色)
我认为这与IDE有关,所以也许您需要在IDE上重新加载项目(Maven项目>在IntelliJ上重新导入)。但是基本上mvn dependency:resolve
应该下载缺少的依赖项(com.datastax.spark:spark-cassandra-connector_2.11:2.3.0
),并且现在应该可以从IDE中获得它。