概述
1.整个项目前后台分离,前台使用angular2
框架,后台使用hibernate4
,spring4
,springMVC
,前台代码写好后,打包放入后台java项目中,然后通过weblogic
发布.
前台ide:webstorm
,后台idea
angular2创建和打包
1.使用angular-cli 创建和打包前台项目
安装angular-cli插件
npm install -g angular-cli
创建新的项目
ng new <project-name>
运行项目
ng server [--port 4201]
命令
1.ng generate
1.1.描述
ng generate [options] 在项目中构建新代码
ng g [options] 简写
支持的类型 用法
类型 | 命令 |
---|---|
Component | ng g component my-new-component |
Directive | ng g directive my-new-directive |
Pipe | ng g pipe my-new-pipe |
Service | ng g service my-new-service |
Class | ng g class my-new-class |
Interface | ng g interface my-new-interface |
Enum | ng g enum my-new-enum |
Module | ng g module my-module |
Route | ng g route my-route当前已禁用 |
构建的组件都会使用自用目录,除非 –flat 单独指定
ng build
构建工件将存储在/dist目录下
ng build可以指定构建目标(--target = production
或--target = development
)和要与该构建一起使用的环境文件(--environment = dev
或--environment = prod
)。 默认情况下,使用开发构建目标和环境。
//这是生产构建
ng build --target=production --environment=prod
ng build --prod --env=prod
ng build --prod
// 这是开发构建
ng build --target=development --environment=dev
ng build --dev --e=dev
ng build --dev
ng build
整合部署
1.新建artifacts
后台java是标准的maven工程结构,将上面/dist下面的所有文件复制到src/main/webapp
下,打开idea的project structure(ctrl+shift+alt+s
),选择artifacts
->add
->web aplication explored
->from module
新建完成需要注意 右侧的output root文件位置是否正确
2.在weblogic中添加刚才新建的artifacts
run
->edit configurations
->’weblogic’->Deployment
->+
3.运行
4.遇到的问题:
1)只能访问到.jsp的文件,其它的都404
原因:在springMVC的配置文件中有拦截器拦截了其它类型文件访问