Windows terminalのデフォルトをwslに変更する
Windows termianlのプレビュー版を開くとpoweshellが開くがwslに変更したい。 Windows terminalのsettingsを開くと次のようなjsonファイルが開かれる。
// To view the default settings, hold "alt" while clicking on the "Settings" button. // For documentation on these settings, see: https://aka.ms/terminal-documentation { "$schema": "https://aka.ms/terminal-profiles-schema", "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", "profiles": [ { // Make changes here to the powershell.exe profile "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", "name": "Windows PowerShell", "commandline": "powershell.exe", "hidden": false }, { // Make changes here to the cmd.exe profile "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", "name": "cmd", "commandline": "cmd.exe", "hidden": false }, { "guid": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}", "hidden": false, "name": "Ubuntu-18.04", "source": "Windows.Terminal.Wsl" }, { "guid": "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}", "hidden": false, "name": "Debian", "source": "Windows.Terminal.Wsl" }, { "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}", "hidden": false, "name": "Azure Cloud Shell", "source": "Windows.Terminal.Azure" } ], // Add custom color schemes to this array "schemes": [], // Add any keybinding overrides to this array. // To unbind a default keybinding, set the command to "unbound" "keybindings": [] }
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
を"defaultProfile": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}",
に変更し再起動するとubuntuがデフォルトで開かれる。
c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40
の値はguidの値をコピペでOK
scalaでjava.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlRootElementが発生する
java11を利用しているときにjava.lang.NoClassDefFoundError
が発生する
CreationException: Unable to create injector, see the following errors: 1) Error injecting constructor, java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlRootElement at play.modules.swagger.SwaggerPluginImpl.<init>(SwaggerPlugin.scala:35) while locating play.modules.swagger.SwaggerPluginImpl at play.modules.swagger.SwaggerModule.bindings(SwaggerModule.scala:11): Binding(interface play.modules.swagger.SwaggerPlugin to ConstructionTarget(class play.modules.swagger.SwaggerPluginImpl) eagerly) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1) while locating play.modules.swagger.SwaggerPlugin
原因
java11ではjavax/xml/bind
のモジュールが削除されたため発生
対策
libraryDependencies ++= Seq("javax.xml.bind" % "jaxb-api" % "2.3.0")
Error: Cannot find module
エラー内容
npm run start:prod internal/modules/cjs/loader.js:638 throw err; ^ Error: Cannot find module 'src/user/user.service'
対策
pathをsrc
から../
に変更する
変更前
import { UserService } from 'src/user/user.service';
変更後
import { UserService } from '../user/user.service';
ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
nestjsでmysqlにアクセスできない
ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
が発生してnestjsのアプリが起動できない状況になった。
- 環境 ubuntu 18.4 mysql 8 nodejs 10
対策
認証方法をmysqk_native_passwordに変更する
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourRootPassword'; -- or CREATE USER 'foo'@'%' IDENTIFIED WITH mysql_native_password BY 'bar'; FLUSH PRIVILEGES;
NestJS学習記録 middleware
Middleware
ミドルウェアは、routeハンドラの前に呼び出される関数。リクエストとレスポンスにアクセスすることができる。ミドルウェアは通常nextという名前で変数名を表す。
ミドルウェアはNestMiddlewareを継承したクラスで@Injectable()
である。
import { Injectable, NestMiddleware } from '@nestjs/common'; @Injectable() export class LooggerMiddleware implements NestMiddleware { use(req: any, res: any, next: () => void) { console.log('Request...'); next(); } }
app.moduleでConfigureに登録することで利用可能になる。
import { Module, NestModule, MiddlewareConsumer } from '@nestjs/common'; import { AppController } from './app.controller'; import { AppService } from './app.service'; import { CatsModule } from './cats/cats.module'; import { LooggerMiddleware } from './loogger.middleware'; @Module({ imports: [CatsModule], controllers: [AppController], providers: [AppService], }) export class AppModule implements NestModule { configure(consumer: MiddlewareConsumer) { consumer .apply(LooggerMiddleware) .forRoutes('cats'); } }