若依前后端打包成jar运行
·
前端修改:
1.修改前端路由 src/router/index.js
修改前:mode: 'history',
修改后:mode: 'hash',
2.修改打包部署根路径 .env.production
修改前:VUE_APP_BASE_API = '/prod-api'
修改后:VUE_APP_BASE_API = '/'
后端修改:
1.修改 admin 模块里面的 com/web/controller/system/SysIndexController.java
修改前:
@RestController
@RequestMapping("/")
return StringUtils.format("欢迎使用{}后台管理框架,当前版本:v{},请通过前端地址访问。", ProjectConfig.getName(), ProjectConfig.getVersion());
修改后:
@Controller
@RequestMapping(value = {"/", "/index"})
return "redirect:/index.html";
2.修改 framework 模块里面的 com/framework/config/SecurityConfig.java
修改前:
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
修改后:
.antMatchers(HttpMethod.GET, "/","/index", "/*.html", "/**/*.html", "/**/*.ico", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers(HttpMethod.GET,"/static/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
3.配置添加<plugin>到 admin 模块中的 pom.xml 里面的<build><plugins>节点下面,保证打包的时候复制 dist 里面的内容到 resources 中的 static 里面
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>copy-frontend-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}/static</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/../vue/dist</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
4.配置添加<plugin>到父 pom.xml 里面的<build><plugins>节点下面,保证打包之前先打包 vue 项目生成 dist 文件夹
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<inherited>false</inherited>
<executions>
<execution>
<id>exec-npm-build</id>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<workingDirectory>${session.executionRootDirectory}/ruoyi-ui</workingDirectory>
<executable>npm</executable>
<arguments>
<argument>run</argument>
<argument>build:prod</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
更多推荐


所有评论(0)