NodeJs 版本: v16.17.0
Yarn 版本: 1.22.19
Npm 版本: 8.15.0
操作系统 版本: Windows11

初始化项目

创建新的 Vue3 ts 项目

yarn create vite

选择 Vue -> TypeScript

添加 vue-router

yarn add vue-router@next

别名配置

修改 vite.config.ts 文件

import {defineConfig} from 'vite'
import {fileURLToPath, URL} from "url"
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [vue()],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url))
        }
    }
})

tsconfig.json 配置


{
  "compilerOptions": {
    "target": "ESNext",
    "useDefineForClassFields": true,
    "module": "ESNext",
    "moduleResolution": "Node",
    "strict": true,
    "jsx": "preserve",
    "sourceMap": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "esModuleInterop": true,
    "lib": ["ESNext", "DOM"],
    "skipLibCheck": true,
    "baseUrl": "./",
    "paths": {
      "@/*": ["./src/*"],
    }
  },
  "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
  "references": [{ "path": "./tsconfig.node.json" }]
}

配置 router

  1. src 目录下创建 router, views 目录
  2. src/router/index.ts 代码
import {createRouter, RouteRecordRaw, Router, createWebHistory} from "vue-router";

const routes: Array<RouteRecordRaw> = [
    {
        path: '/',
        name: 'Home',
        component: () => import('@/views/Home.vue'),
    }
]

const router: Router = createRouter({
    history: createWebHistory(),
    routes
})

export default router

  1. src/main.ts 代码
import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import router from "@/router";

createApp(App)
    .use(router)
    .mount('#app')


  1. src/App.vue 代码
<script setup lang="ts">

</script>

<template>
  <router-view/>

</template>

<style scoped>

</style>

  1. src/views/Home.vue 代码
<script setup lang="ts">
import HelloWorld from '@/components/HelloWorld.vue'

</script>
<template>
  <HelloWorld msg="Vite + Vue" />
</template>

运行截图
image

使用Spring boot 3 + gradle 学习时遇到一个奇怪的错误
spring boot gradle 同时使用lombok 和 mapstruct 报错 Parameter 1 of constructor in xxxx.xxxx.xxx.service.impl.xxxxServiceImpl required a bean of type ’ xxxx.xxxx.xxx.service.mapstruct.xxxxxMapper’ that could not be found.
抛出的异常: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘xxx.xxx.xxx.service.mapstruct.xxxMapper’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

当时很奇怪,通过搜索引擎发现,大多数的结果都是在启动类添加@ComponentScan、@MapperScan 等等
后来怀疑是怀疑是因为引入依赖的方式不正球,后面刚好看到一篇文章:当 Lombok 遇见了 MapStruct の「坑」里面提到 “Lombok 和 MapStruct 都是利用「Annotation Processor」在程序编译时生成代码的” 顿时意识到我引入依赖的方式错了

我的引入方式

implementation 'org.mapstruct:mapstruct:1.5.5.Final'
implementation 'org.mapstruct:mapstruct-processor:1.5.5.Final'

正确引入方式

implementation 'org.mapstruct:mapstruct:1.5.5.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.5.Final'

兜了一个大圈子/无辜脸/

要将nginx配置为Spring Boot应用程序的反向代理,可以按照以下步骤进行操作:

  1. 确保你的Spring Boot应用程序正在侦听本地主机和端口。例如,如果你的应用程序正在侦听端口8080,请使用以下命令启动应用程序:
java -jar myapp.jar --server.port=8080
  1. 在nginx配置文件中创建一个服务器块(server block),该块将包含你要反向代理的Spring Boot应用程序的配置。例如:
server {
    listen 80;
    server_name example.com;
    
    location / {
        proxy_pass http://localhost:8080;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

在这个例子中,我们在80端口上侦听HTTP请求,并将它们代理到localhost:8080。 proxy_pass指令用于将请求转发到你的Spring Boot应用程序的实际位置。 proxy_set_header指令用于配置要发送给Spring Boot应用程序的标头,例如客户端的IP地址和主机名。
3. 在你的DNS记录中,将域名“example.com”指向nginx服务器的公共IP地址。
4. 重新加载nginx配置文件以使更改生效。在Ubuntu上,可以使用以下命令重载配置文件:

sudo service nginx reload

完成这些步骤后,nginx服务应该已经成功配置为反向代理到你的Spring Boot应用程序,将所有来自Internet的请求代理到你的应用程序。

在Hyper-V下Windows系虚拟机默认就能够开启增强会话。
增强会话下虚拟机可以很方便的和宿主机共享剪切板与文件,并且在增强会话开启时也能够方便的调整分辨率。
而Ubuntu等Linux系统下则默认为基本会话,分辨率的调整需要修改引导文件,而剪切板和宿主机是独立的非常不方便。

1. Ubuntu20.04 虚拟机下安装

wget https://raw.githubusercontent.com/Hinara/linux-vm-tools/ubuntu20-04/ubuntu/20.04/install.sh

chmod +x install.sh

sudo ./install.sh

2. Windows 管理员权限运行 Power Shell

关闭虚拟机
powerShell 下运行, 获取虚拟机名称

Get-VM 
Set-VM -VMName <虚拟机名称> -EnhancedSessionTransportType HvSocket

打开虚拟机,连接-> 即可弹出设置分辨率窗口
20221208230229