【问题标题】:Using Intellij with Spring-Data-Neo4j /w Aspectj gives Java error when trying to create the Repos尝试创建 Repos 时将 Intellij 与 Spring-Data-Neo4j /w Aspectj 一起使用会导致 Java 错误
【发布时间】:2014-01-23 03:27:38
【问题描述】:

我正在使用 Intellij v13 编写 Spring-Data(使用 AspectJ + Neo4j)。如果我有以下服务文件:

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class BaseClassRepositoryImpl implements BaseClassRepository{
}

public interface BaseClassRepository extends BaseClassRepositoryCustom, GraphRepository<BaseClass> {

}

使用example,上面的代码应该可以工作。但是,Intellij 给了我一个例外:

java: local.ffxiv.repos.BaseClassRepositoryImpl is not abstract and does not override     abstract method findByName(java.lang.String) in local.ffxiv.repos.BaseClassRepository

我到处搜索,试图找出 Intellij 这样做的原因。其他人看到了吗?

这也是 build.gradle 脚本:

project.ext {
    sourceCompatibility = "1.7"
    targetCompatibility = "1.6"
    springDataGraphVersion = "2.3.0.RC1"
    springVersion = "4.0.0.RELEASE"
    junitVersion = "4.11"
    neo4jVersion = "2.0.0"
    aspectjVersion = "1.7"
}
apply from: 'http://github.com/SpringSource/spring-data-neo4j/raw/master/build/gradle/springdataneo4j.gradle'

configurations {
    runtime
    testCompile
}

buildscript {
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:0.5.0.M7")
    }
    repositories {
        maven { url "http://repo.spring.io/milestone" }
        mavenCentral()
    }
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'spring-boot'

jar {
    baseName = 'ffxiv_db'
    version = '0.1.0'
}
repositories {
    mavenLocal()
    mavenCentral()
    maven { url "http://repo.spring.io/libs-milestone" }
    maven { url "http://repo.spring.io/milestone" }
    maven { url "http://m2.neo4j.org" }
}

dependencies {

    // compile list
    compile "org.springframework.boot:spring-boot-starter:0.5.0.M7"
    compile "org.springframework.data:spring-data-neo4j:$springDataGraphVersion"
    compile "org.springframework.data:spring-data-neo4j-aspects:$springDataGraphVersion"
    compile "org.neo4j:neo4j:$neo4jVersion"
    compile "javax.validation:validation-api:1.0.0.GA"
    compile "org.springframework:spring-aspects:$springVersion"

    // Test dependencies
    testCompile "org.springframework:spring-test:$springVersion"
    testCompile "junit:junit:$junitVersion"
    testCompile "org.neo4j:neo4j-kernel:$neo4jVersion:tests"
}

task wrapper(type: Wrapper) {
    gradleVersion = '1.10'
}

这是要求我实现我不需要做的存在(长),但 IntelliJ 一直告诉我。如果我在弹出消息上按 Alt+Enter,我可以点击“实现方法”,它会创建一大堆带有空返回值的覆盖。但是,根据文档,它应该通过函数的名称推断出我想要做什么,并得出该函数对简单 CRUD 操作的作用。 IE。 for 'findByName' 应该返回一个名为“Name”的属性并创建正确的函数。

【问题讨论】:

标签: java spring intellij-idea neo4j spring-data


【解决方案1】:

异常消息很清楚:local.ffxiv.repos.BaseClassRepositoryImpl 类应该被声明为抽象类或者必须实现local.ffxiv.repos.BaseClassRepositoryfindByName(java.lang.String) 方法(它扩展了BaseClassRepositoryCustom,我猜findByName 是声明)。

与您引用的示例比较:WorldRepositoryImpl 实现 MyWorldRepository 并覆盖其所有方法。

UPD

您的BaseClassRepositoryImpl 可能应该实现BaseClassRepositoryCustom 而不是BaseClassRepository。然后你将不得不只覆盖 BaseClassRepositoryCustom 的方法,而不是整个 GraphRepository

【讨论】:

  • 嗯,我明白了。我会发布它的截图。 IntellJ 希望我实现 20 种我不需要做的方法(根据 Spring/AspectJ 的工作原理)。
  • 添加了上面的截图和更多信息。也请不要说我的接口“BaseClassRepository”本身没有功能。
  • 大坝,@Eugene,我怎么没注意到这种关系。是的,我做错了。感谢您的指导。
猜你喜欢
  • 1970-01-01
  • 2014-06-04
  • 1970-01-01
  • 2011-03-12
  • 1970-01-01
  • 1970-01-01
  • 2011-06-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多