org.apache.wicket.markup.MarkupNotFoundException:无法确定标记。组件尚未连接到父

时间:2017-11-29 16:52:33

标签: java eclipse wicket junit5 gradle-eclipse

  

我运行gradle脚本,依赖于jupiter,wicket spring boot start和springboot starter

buildscript {
    repositories {
        mavenCentral()
        // The following is only necessary if you want to use SNAPSHOT releases.
        // maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
    }
    dependencies {
        classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.2'
    }
}

apply plugin: 'org.junit.platform.gradle.plugin'

// Apply the java-library plugin to add support for Java Library
apply plugin: 'java'

junitPlatform {
    reportsDir file('build/test-results/junit-platform') // this is the default
    enableStandardTestTask true
    // selectors (optional)
    // filters (optional)
}

// In this section you declare where to find the dependencies of your project
repositories {
    // Use jcenter for resolving your dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
}

dependencies {// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter
compile group: 'org.springframework.boot', name: 'spring-boot-starter', version: '1.5.9.RELEASE'
// https://mvnrepository.com/artifact/com.giffing.wicket.spring.boot.starter/wicket-spring-boot-starter
compile group: 'com.giffing.wicket.spring.boot.starter', name: 'wicket-spring-boot-starter', version: '2.0.4'
}

dependencies {
    testCompile("org.junit.jupiter:junit-jupiter-api:5.0.2")
    testRuntime("org.junit.jupiter:junit-jupiter-engine:5.0.2")
}

dependencies {
    testCompile("junit:junit:4.12")
    testRuntime("org.junit.vintage:junit-vintage-engine:4.12.2")
}
  

在测试中

package steinKo.ATM.Web.test.unit;
import org.apache.wicket.util.tester.WicketTester;
import org.junit.jupiter.api.Test;

class HomePageTest {
    private WicketTester tester;

    @Test
    public void shouldRender() {
        tester = new WicketTester();
        tester.startPage(HomePage.class);
        tester.assertRenderedPage(HomePage.class);
    }
}
  

在课堂上

package steinKo.ATM.Web;

import org.apache.wicket.markup.html.WebPage;

public class HomePage extends WebPage{

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

}
  

使用html

     

插入   这里的标题

     

     

我发现了以下错误消息

     

2:57:15.185 [main] DEBUG   org.apache.wicket.core.util.resource.locator.ResourceStreamLocator -   试图找到资源&org / apache / wicket / Page.html'运用   发现者' [webapppath:/]' 22:57:15.185 [主要]调查   org.apache.wicket.core.util.resource.locator.ResourceStreamLocator -   试图找到资源&org / apache / wicket / Page.html'运用   查找者' [classpath:META-INF / resources /]' 22:57:15.186 [主要] DEBUG   org.apache.wicket.markup.MarkupCache - 未找到标记:   steinKo.ATM.Web.HomePage_nb_NO.html 22:57:15.195 [main] DEBUG   org.apache.wicket.page.PageAccessSynchronizer - ' main'试图   获取锁定到ID' 0' 22:57:15.195 [主要] DEBUG   org.apache.wicket.page.PageAccessSynchronizer - 主要获取锁定   第0页22:57:15.229 [主要]警告RequestCycleExtra -   ******************************** 22:57:15.232 [main] WARN RequestCycleExtra - 处理以下异常   org.apache.wicket.markup.MarkupNotFoundException:无法确定   标记。组件尚未连接到父级。 [Page class =   steinKo.ATM.Web.HomePage,id = 0,render count = 1]

     

我认为错误是由于Gradle中Homepage.java和HomePage.hlml之间缺乏联系造成的   我怎么能修复这个错误?

1 个答案:

答案 0 :(得分:0)

  

解决方案

sourceSets {
    main {
        java {
            srcDirs = ['src/main/java']
        }
        resources {
            srcDirs = ['src/main/java','src/main/resources']
        }
    }
}