Fab*_*ano 5 jhipster visual-studio-code
我使用 JHipster 7.0.0 生成了一个应用程序。它的 applicationType 为“monolith”,prodDatabaseType 为“postgressql”,devDatabaseType 为“h2Disk”。
当我运行命令行“./mwnw”时,应用程序完美启动。
当我尝试按照以下说明在 VSCode IDE 中调试应用程序时,问题就出现了: https: //www.jhipster.tech/development/。我右键单击 Application 类的文件(带有 @SpringBootApplication 注释的文件),单击“调试 Java”菜单,在启动过程中出现以下异常:
2021-04-02 18:51:36.143 DEBUG 46054 --- [ main] br.gov.mypackage.config.WebConfigurer : Initialize H2 console
2021-04-02 18:51:36.145 WARN 46054 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is java.lang.RuntimeException: java.lang.RuntimeException: Failed to load and initialize org.h2.server.web.WebServlet
2021-04-02 18:51:36.251 ERROR 46054 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is java.lang.RuntimeException: java.lang.RuntimeException: Failed to load and initialize org.h2.server.web.WebServlet
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:162)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:769)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:326)
at br.gov.ancine.JhipsterLearnApp.main(JhipsterLearnApp.java:69)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Failed to load and initialize org.h2.server.web.WebServlet
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:257)
at org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory.createManager(UndertowServletWebServerFactory.java:345)
at org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory.getWebServer(UndertowServletWebServerFactory.java:314)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:181)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:159)
... 7 common frames omitted
Caused by: java.lang.RuntimeException: Failed to load and initialize org.h2.server.web.WebServlet
at tech.jhipster.config.h2.H2ConfigurationHelper.initH2Console(H2ConfigurationHelper.java:128)
at br.gov.ancine.config.WebConfigurer.initH2Console(WebConfigurer.java:119)
at br.gov.ancine.config.WebConfigurer.onStartup(WebConfigurer.java:52)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:234)
at org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory$Initializer.onStartup(UndertowServletWebServerFactory.java:504)
at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:204)
at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:187)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:255)
... 11 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.h2.server.web.WebServlet
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:398)
at tech.jhipster.config.h2.H2ConfigurationHelper.initH2Console(H2ConfigurationHelper.java:119)
... 20 common frames omitted
Run Code Online (Sandbox Code Playgroud)
看起来 VSCode 的类路径中不包含 h2database。
答案如下:
在根应用程序文件夹中运行:
mvn spring-boot:运行-D“spring-boot.run.jvmArguments”=“-Xdebug -Xrunjdwp:传输= dt_socket,服务器= y,挂起= y,地址= 5005”
{“版本”:“0.2.0”,“配置”:[
{
"type": "java",
"name": "Debug (Launch)",
"request": "launch",
"mainClass": "",
"args": ""
},
{
"type": "java",
"name": "Debug (Attach)",
"request": "attach",
"hostName": "localhost",
"port": 8000
}
Run Code Online (Sandbox Code Playgroud)
] }
归档时间: |
|
查看次数: |
1343 次 |
最近记录: |