我看到的使用Gradle + Spring-data-neo4j + Aspectj的大多数配置都是针对Eclipse和/或使用Maven的。 我看不到找到完整的设置才能正常工作。

这是我的build.gradle:

apply plugin:'base'
apply plugin:'java'
apply plugin:'idea'

buildscript {
    repositories {
        maven {
            url "https://maven.eveoh.nl/content/repositories/releases"
        }
    }
    dependencies {
        classpath "nl.eveoh:gradle-aspectj:1.4"
    }
}

repositories {
    maven {
        url "http://m2.neo4j.org/content/repositories/releases/"
    }
    mavenCentral()
    mavenLocal()
}

project.ext {
    springVersion = "4.0.3.RELEASE"
    neo4jVersion = "2.0.1.RELEASE"
    springDataGraphVersion = "3.0.1.RELEASE"
    aspectjVersion = "1.7.4"

    sourceCompatibility = 1.7
    targetCompatibility = 1.7
}

apply plugin: 'aspectj'

compileAspect {
    xlint = 'warning'
}

dependencies {
    compile 'org.slf4j:slf4j-api:1.7.6'

    compile "org.springframework:spring-context:${springVersion}"
    compile "org.neo4j:neo4j:${neo4jVersion}"
    // Provides Repository based Object <-> Graph Mapping
    compile "javax.validation:validation-api:1.0.0.GA"
    compile "org.springframework.data:spring-data-neo4j-aspects:${springDataGraphVersion}"
    compile 'javax.persistence:persistence-api:1.0-rev-1'


    testCompile 'junit:junit-dep:4.11'
    testCompile "org.springframework:spring-test:${springVersion}"
    testCompile 'org.hamcrest:hamcrest-all:1.3'
    // Access to Neo4j testing facilities: TestGraphDatabaseFactory
    testCompile "org.neo4j:neo4j-kernel:${neo4jVersion}:tests@jar"
    testRuntime 'org.slf4j:slf4j-simple:1.7.5'

    //aspectj dependencies
    aspectpath "org.aspectj:aspectjtools:${aspectjVersion}"
    compile "org.aspectj:aspectjrt:${aspectjVersion}"
    aspectpath group: "org.springframework.data", name: "spring-data-neo4j", version: springDataGraphVersion
}

configurations {
    runtime
    compileJava
    testCompileJava
}

// Generate wrapper for Gradle
task wrapper(type: Wrapper) {
    gradleVersion = '1.11'
}

当前文档似乎没有其中的Aspectj gradle信息。 我使用了2.3.5.RELEASE中的信息,该信息已合并到此版本中。 我还为编译器设置了ajc,但是我仍然认为缺少一些东西,因为那已经很旧了。 另外,我不是在使用pom.xml,而是在下面的Java配置文件。

@Configuration
@ComponentScan(basePackages = "domains")
@EnableNeo4jRepositories(basePackages = "repos")
//@EnableSpringConfigured
@EnableTransactionManagement
public class AppConfigTest extends Neo4jAspectConfiguration {

    public AppConfigTest () {
        setBasePackage("domains");
    }

    @Bean (destroyMethod = "shutdown")
    public GraphDatabaseService graphDatabaseService() {
        return new TestGraphDatabaseFactory().newImpermanentDatabase();
    }

}

============== [编辑1] =================

使用下面的@StefanArmbruster指出的项目eveoh / gradle-aspectj更新了上面的Gradle构建文件。 但是,现在出现此错误:

* Where:
Build file 'build.gradle' line: 52
> Could not find method aspectpath() for arguments [org.aspectj:aspectjtools:1.7.4] on root project

============== [编辑2] =================

更新了Gradle版本,暂时解决了上述问题,但现在我遇到了这个问题:

10:44:10 AM: Executing external task 'build'...
:processResources UP-TO-DATE
:compileAspect FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileAspect'.
> Error creating temporary file

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 42.556 secs
Permission denied
10:44:53 AM: External task execution finished 'build'.

===============>>#1 票数:3 已采纳

终于使它起作用了(至少它的这一部分)。 最终build.gradle:

apply plugin:'base'
apply plugin:'java'
apply plugin:'idea'

buildscript {
    repositories {
        maven {
            url "https://maven.eveoh.nl/content/repositories/releases"
        }
    }
    dependencies {
        classpath "nl.eveoh:gradle-aspectj:1.4"
    }
}

repositories {
    maven {
        url "http://m2.neo4j.org/content/repositories/releases/"
    }
    mavenCentral()
    mavenLocal()
}

project.ext {
    springVersion = "4.0.3.RELEASE"
    neo4jVersion = "2.0.1.RELEASE"
    springDataGraphVersion = "3.0.1.RELEASE"
    aspectjVersion = "1.7.4"

    sourceCompatibility = 1.7
    targetCompatibility = 1.7
}

apply plugin: 'aspectj'

compileAspect {
    xlint = 'warning'
}

dependencies {
    compile 'org.slf4j:slf4j-api:1.7.6'

    compile "org.springframework:spring-context:${springVersion}"
    compile "org.neo4j:neo4j:${neo4jVersion}"
    // Provides Repository based Object <-> Graph Mapping
    compile "javax.validation:validation-api:1.0.0.GA"
    compile "org.springframework.data:spring-data-neo4j-aspects:${springDataGraphVersion}"
    compile 'javax.persistence:persistence-api:1.0-rev-1'


    testCompile 'junit:junit-dep:4.11'
    testCompile "org.springframework:spring-test:${springVersion}"
    testCompile 'org.hamcrest:hamcrest-all:1.3'
    // Access to Neo4j testing facilities: TestGraphDatabaseFactory
    testCompile "org.neo4j:neo4j-kernel:${neo4jVersion}:tests@jar"
    testRuntime 'org.slf4j:slf4j-simple:1.7.5'

    //aspectj dependencies
    aspectpath "org.aspectj:aspectjtools:${aspectjVersion}"
    compile "org.aspectj:aspectjrt:${aspectjVersion}"
    aspectpath group: "org.springframework.data", name: "spring-data-neo4j", version: springDataGraphVersion
}

configurations {
    runtime
    compileJava
    testCompileJava
}

// Generate wrapper for Gradle
task wrapper(type: Wrapper) {
    gradleVersion = '1.11'
}

构建脚本的位置,额外的属性和apply插件'aspectj'很重要。 我必须去弄弄我需要的顺序,而我已经有了。

我认为我仍然没有适当地编织,但这是一个不同的话题。

  ask by flamusdiu translate from so

未解决问题?本站智能推荐: