简体   繁体   中英

Main method not found - Maven Project

I'm currently trying to create my first maven project in VSCode, I have all the dependencies and extensions/plugins, however I'm getting a main method not found error even tho it's clearly declared.

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class App{
public static void main(String[]args) {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\xxx\chromedriver.exe"
WebDriver driver = new ChromeDriver();
driver.get("https://www.google.com/")
WebElement p =driver.findElement(By.cssSelector("a[href*='https://www.gooogle2.com/");
driver.quit();
}
}

I omitted some code due to the sake of time and not being able to copy/paste from my work laptop. Any help is much appreciated

You don't have a space between your main(String[] args){} . You're also missing a closing parentheses on line 7. Try to run after fixing said problems, after which you should try

$ mvn clean
$ mvn compile
$ mvn exec:java -Dexec.mainClass=com.example.App

in the root directory of your project.

Replace com.example with the package your main class resides in.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM