dropwizard 一般作为restfull的开发框架来使用,实际上它也是一个http web服务器,只是这块好像不是主业,官网的文档对这块的介绍也不是很完整,导致初学者对这块往往搞不明白。
设置如下:
1.HelloWorldApplication中initialize方法添加绑定
public void initialize(Bootstrap<HelloWorldConfiguration> bootstrap) {
// 参数1:资源文件路径:相对于code src/main/resources/
//参数2: urlPath,就是访问的相对路径
//参数3: 首页文件
//参数4: 绑定名称
bootstrap.addBundle(new AssetsBundle( "/angular/", "/angular/", "index.html", "angular"));
}
2. yml设置http 服务器信息
server:
type: simple
applicationContextPath: /
connector:
type: http
port: 8080
applicationContextPath一定要设置,不然就报404错误。
备注:测试时可以先用简单的静态页面helloworld,通过了再用复杂页面。
亲测支持angular。