没有主要方法的Java WebApp Project的Visual Studio代码设置 [英] Visual Studio Code setup for Java WebApp Project without main method

查看:47
本文介绍了没有主要方法的Java WebApp Project的Visual Studio代码设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望设置此项目(

  1. 添加tomcat服务器并在tomcat上运行.war,这是一个gif教程:

    如果可以成功运行它,则可以进行调试:右键单击tomcat服务器,然后选择调试war软件包:

    I am looking to setup this project ( https://github.com/afawcett/githubsfdeploy) on my local machine. I'm not too familiar with Java but I feel I've been able to do enough (MAVEN, JAVA environment downloads and system variable settings) to get my windows machine up and running along with Visual Studio Code. I was able to get the spring boot project up and running in visual studio code without any issues so I want to believe I have all the required pieces (https://code.visualstudio.com/docs/java/java-spring-boot).

    The spring-boot project has a main method and the one I'm trying to recreate doesn't. I am receiving the error when debugging the githubsfdeploy project that a "main" method could not be found. I've been researching other ways to run a java project without using the main method but haven't recognized the missing piece yet. Would love some direction on what I may not be taking into account. Thanks!

    解决方案

    This is a Maven project which based on the concept of a project object model (POM). So first, you should download Maven and Tomcat locally.

    My machine: win10, vscode1.49.0, JDK11

    VS Code Extension installed: Java Extension Pack, Tomcat for java

    and i download: apache-maven-3.6.3-bin.zip and Tomcat9.0.38 and extract them

    1. Add maven to Environment Variables:

      ---\apache-maven-3.6.3-bin\apache-maven-3.6.3\bin

    2. Open the project in VS Code, add the following code in User settings.json:

      "maven.executable.path": "---\apache-maven-3.6.3-bin\apache-maven-3.6.3\bin\mvn",

    3. Follow the picture steps:

    1. Add the tomcat server and run the .war on tomcat, here is a gif tutorial: work with tomcat

    Finally, you will observe this result:

    When you can run it successfully, debugging is achievable: right click the tomcat server and choose debug war packages:

    这篇关于没有主要方法的Java WebApp Project的Visual Studio代码设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆