江西省网站建设_网站建设公司_博客网站_seo优化
2026/1/8 2:08:53 网站建设 项目流程

后端目录及配置​

后端目录​

后端目录

. ├─ src # 工作目录 │ ├─ main │ ├─ ├─ java │ ├─ ├─ ├─ net │ ├─ ├─ ├─ ├─ diaowen │ ├─ ├─ ├─ ├─ ├─ common # 公共类目录,如LOGIN、SMS、Storage... │ ├─ ├─ ├─ ├─ ├─ dwsurvey │ ├─ ├─ ├─ ├─ ├─ ├─ common # 调问公共类目录 │ ├─ ├─ ├─ ├─ ├─ ├─ config # springboot配置目录 │ ├─ ├─ ├─ ├─ ├─ ├─ controller 控制层目录 │ ├─ ├─ ├─ ├─ ├─ ├─ dao 数据层目录 │ ├─ ├─ ├─ ├─ ├─ ├─ entity 实体类目录 │ ├─ ├─ ├─ ├─ ├─ ├─ service 业务层目录 │ ├─ ├─ resource # 配置文件目录 │ ├─ ├─ ├─ application.yml # 配置入口 │ ├─ ├─ ├─ application-dev.yml # 开发环境配置 │ ├─ ├─ ├─ application-prod.yml # 生产环境配置 │ ├─ ├─ ├─ application-test.yml # 测试环境配置 └─ pom.xml # maven包管理

后端配置​

通常配置哪些

此处只介绍几处可能会修改的关键配置 通常情况下你只需要修改 mysql 及 elasticsearch 连接信息

不配置 elasticsearch 影响

如果体验预览可以不配置 elasticsearch,但这会使得统计报告无法使用,不影响系统其它功能。

src/main/resources/application-dev.yml

yml

dwsurvey: # 用户模式切换,暂且保持默认 local, test,demo site: "local" # 服务占用的端口号 server: port: 8080 tomcat: max-http-form-post-size: -1 # Spring相关配置 spring: # 数据库配置 datasource: #type: com.alibaba.druid.pool.DruidDataSource # 连接URL url: jdbc:mysql://localhost:3306/dwsurvey?useUnicode=true&characterEncoding=utf8 # 连接账号 username: root # 连接密码 password: 123456,. ... # 日志配置 # elasticsearch 配置,不配置不会影响正常设计问卷及答卷,但无法使用统计报告 elasticsearch: username: elastic passwd: A0ThxyWi1gMNJzv7iU7M apikey: == hosts: 127.0.0.1:9200 # 多个IP逗号隔开 cert-name: http_ca.crt # 后加的ES参数 # 协议方式,使用证书这里改成https scheme: http # 索引统一前缀,默认为空不加前缀, 如果加建议格式如:dw_ index-prev: oss_ # 认证方式 noPwd, pwd, cert security: noPwd

前端目录及配置​

前端目录​

社区版目录企业版目录

. ├─ build # 构建配置 ├─ config # 项目配置 │ ├─ dev.env.js # 开发环境配置 │ ├─ index.js # 主配置 │ ├─ prod.env.js # 生产环境配置 │ └─ test.env.js # 测试环境配置 ├─ src │ ├─ api # 接口API │ ├─ assets # 资源 │ ├─ components # 项目组件 │ ├─ ├─ common # 公共组件 │ ├─ ├─ dw-survey-comp # 问卷相关组件 │ ├─ ├─ ├─ dw-answer-comp # 回答问卷组件 │ ├─ ├─ ├─ dw-data-comp # 问卷数据组件 │ ├─ ├─ ├─ dw-design-comp # 设计问卷组件 │ ├─ ├─ ├─ dw-utils # 一些帮助文件 │ ├─ ├─ layouts # 系统布局组件 │ └─ router # 系统路由配置 │ └─ theme # 系统主题配置 │ └─ utils # 系统工具文件 │ └─ views # 系统页面文件 └─ package.json # 包管理

前端配置​

社区版​

TIP

开发环境如果使用 localhost 访问不需要修改, 只用修改config/index.js里的dev.proxyTable.target地址为后端地址

TIP

如果生产打开请修改 config/prod.env.js 修改为前端实现访问地址,然后配置 nginx 转发

config/dev.env.js

js

/** * 注意:开发环境不需要修改这里 * 只需要修改 index.js dev.proxyTable.target地址为后端地址 */ "use strict"; const merge = require("webpack-merge"); const prodEnv = require("./prod.env"); module.exports = merge(prodEnv, { NODE_ENV: '"development"', // 本地开发环境后端API地址不需要在这个文件配置,在config/index.js里面配置target DW_API_URL: '"http://localhost:8081"', //开发环境不需要修改,只需要 config/index.js target DW_WEB_URL: '"http://localhost:8081"', //开发环境不需要修改,只需要 config/index.js target DW_RESOURCE_URL: '"http://localhost:8080"', });

config/index.js

js

"use strict"; // Template version: 1.3.1 // see http://vuejs-templates.github.io/webpack for documentation. const path = require("path"); module.exports = { dev: { // Paths assetsSubDirectory: "static", assetsPublicPath: "/", proxyTable: { "/api": { target: "http://localhost:8080/", // 本地开发环境只需要修改这个配置,修改为后端服务地址即可 changeOrigin: true, //如果需要跨域 pathRewrite: { "^/api": "/api", }, }, }, ... }, ... };

企业版​

config/.env.development

js

/** * 注意:修改这里为后端实现地址, * 也可以不修改这个,只修改 vite.config server.proxy.target 地址为后端地址 */ NODE_ENV = "development"; VITE_DW_API_URL = "http://localhost:5173"; VITE_DW_WEB_URL = "http://localhost:5173"; VITE_DW_RESOURCE_URL = "http://localhost:5173";

nginx 配置​

token 认证方式​

conf.d目录下面新建dwsurvey.conf,并配置如下内容

conf.d/dwsurvey.conf

conf

server { listen 80; server_name _; root /www/sf/dist; index index.html; location / { index index.html index.htm; try_files $uri $uri/ /index.html; } location /api { # rewrite ^/api/(.*) /$1 break; proxy_pass http://localhost:8899; } location /file { # rewrite ^/api/(.*) /$1 break; proxy_pass http://localhost:8899; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } }

编辑nginx.conf的配置引用include /etc/nginx/conf.d/dwsurvey.conf;如下所示

include /etc/nginx/conf.d/*.conf;

效果如图

session 认证方式​

conf.d目录下面新建dwsurvey.conf,并配置如下内容

conf.d/dwsurvey.conf

conf

server { listen 80; server_name _; root /www/sf/dist; index index.html; location / { index index.html index.htm; try_files $uri $uri/ /index.html; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } }

编辑nginx.conf的配置引用include /etc/nginx/conf.d/dwsurvey.conf;如下所示

include /etc/nginx/conf.d/*.conf;

效果如图

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询