【发布时间】:2013-10-19 01:33:43
【问题描述】:
1.
我正在使用 Spring Boot。我的主课很简单
@ComponentScan
@EnableAutoConfiguration
@Configuration
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
#2。现在我想将我的静态内容外部化到一个 jar 文件中。所以,下面是jar项目
/pom.xml
/src/main/resources/META-INF/resources/hello.json // here is my resource
我做maven install并将依赖项放入主应用程序,正常运行应用程序。现在我可以调用 http://localhost:8080/hello.json 来获取我的 hello.json 文件
#3。然后,下一步是为我的主要 Web 项目使用 Apache Tiles,因此我创建了一个 @EnableWebMvc 类来配置 tilesViewResolver
@Configuration
@EnableWebMvc
public class WebMvcConfiguration extends WebMvcConfigurerAdapter {
public @Bean TilesViewResolver tilesViewResolver() {
return new TilesViewResolver();
}
public @Bean TilesConfigurer tilesConfigurer() {
TilesConfigurer ret = new TilesConfigurer();
ret.setDefinitions(new String[] { "classpath:tiles.xml" });
return ret;
}
}
然后我再次启动应用程序并尝试hello.json 以确保一切正常。但是,出现了 404 页面。删除WebMvcConfiguration 还给我的hello.json。
我应该做哪些配置来解决这个问题?
非常感谢。
【问题讨论】:
标签: spring spring-mvc spring-boot