未找到nashorn加载脚本

时间:2016-10-28 13:27:19

标签: java spring maven nashorn isomorphic

我将spring boot app的视图配置设置为:

@Configuration
public class ViewConfig extends WebMvcConfigurerAdapter {

    public static final String[] SCRIPTS = {
            "nashorn/ejs.min.js",
            "nashorn/polyfill.js",
            "nashorn/render.js"
    };

    @Bean
    public ViewResolver viewResolver() {
        ScriptTemplateViewResolver viewResolver = new ScriptTemplateViewResolver();
        viewResolver.setPrefix("templates/");
        viewResolver.setSuffix(".ejs");

        return viewResolver;
    }

    @Bean
    public ScriptTemplateConfigurer viewConfigurer() {
        ScriptTemplateConfigurer configurer = new ScriptTemplateConfigurer();
        configurer.setEngineName("nashorn");
        configurer.setScripts(SCRIPTS);
        configurer.setRenderFunction("render");
        configurer.setSharedEngine(false);

        return configurer;
    }
}

和我的maven结构:

App
|-- pom.xml
`-- src
    |-- main
        |-- java
        |   `-- config
        |             `-- ViewConfig.java
        |   `-- Application.java
        |-- resources
        |   `-- nashorn
        |       `-- ejs.min.js
        |       `-- polyfill.js
        |       `-- render.js
        |   `-- templates
        |       `-- index.ejs

然而,当我使用命令mvn spring-boot:run运行时,我遇到了一个问题,无法根据原因加载脚本:

java.lang.IllegalStateException: Resource [nashorn/ejs.min.js] not found

我的目的是我想用Java和ReactJs构建一个同构的应用程序但是我在一周前遇到了这些问题,直到现在我无法解决这些问题。

0 个答案:

没有答案