vue3整合springboot打完整jar包
作者:华山令狐虫
本文主要介绍了vue3整合springboot打完整jar包,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
前端
- .env.developmen
VITE_APP_BASE_URL='/api'
- .env.production
VITE_APP_BASE_URL='/'
axios 配置
axios.defaults.baseURL = import.meta.env.VITE_APP_BASE_URL
package.json
"scripts": {
"dev": "vite --mode development",
"build": "vite build --mode production"
}vite.config.js
server: {
port: 4000, //设置服务启动端口号,是一个可选项,不要设置为本机的端口号,可能会发生冲突
open: true, //是否自动打开浏览器,可选项
cors: true, //允许跨域。
// 设置代理
proxy: {
'/api': {
target: 'http://localhost:8053/', //这是你要跨域请求的地址前缀
changeOrigin: true, //开启跨域
rewrite: (path) => path.replace(/^\/api/, '')
}
}
}后端
pom.xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>exec-pnpm-install</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>pnpm</executable>
<arguments>
<argument>install</argument>
</arguments>
<workingDirectory>${basedir}/src/ui</workingDirectory>
</configuration>
</execution>
<execution>
<id>exec-pnpm-run-build</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>pnpm</executable>
<arguments>
<argument>build</argument>
</arguments>
<workingDirectory>${basedir}/src/ui</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>到此这篇关于vue3整合springboot打完整jar包的文章就介绍到这了,更多相关vue3 springboot打jar包内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
