Home > database >  Why does Selenium work for me in IntelliJ but fail when I run my jar in the command line?
Why does Selenium work for me in IntelliJ but fail when I run my jar in the command line?

Time:01-02

I set up Selenium version 4.7.1 in my project in IntelliJ using maven. In order to get past enter image description here

CodePudding user response:

Probably you aren't building dependencies correctly. U need both:

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.6</version>
                <configuration>

                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                            <addDefaultImplementationEntries>false</addDefaultImplementationEntries>
                            <packageName>your package</packageName>
                            <mainClass>your class</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                            <includeScope>compile</includeScope>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

It's hard to help if you don't post your pom.xml though

  • Related