I am struggling to run unit tests or main methods in IntelliJ via the 'Run' button. (Project was set up via maven)
Here is my pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.andrew.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<url>http://maven.apache.org</url>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Here is my project directory:
├── my-app.iml
├── pom.xml
├── src
│ ├── main
│ │ └── java
│ │ └── com
│ │ └── andrew
│ │ ├── app
│ │ └── Hello.java
│ └── test
│ └── java
│ └── com
│ └── andrew
│ ├── app
│ └── HelloTest.java
└── target
├── classes
│ └── com
│ └── andrew
│ └── Hello.class
├── generated-sources
│ └── annotations
└── maven-status
└── maven-compiler-plugin
└── compile
└── default-compile
├── createdFiles.lst
└── inputFiles.lst
I have tried the followings:
- Setting Project's compiler output to
{project directory}/target
- Invalidate cache and restart, rebuild
- Running
java com.andrew.Hello
in ./target/classes returnsHello World
- Set
./src/main/java
as Source
But I still can't fix the issue.