先直接上手:
创建空的项目:
根据提示,创建新的module,也可以先进入项目在创建module
创建Maven项目,直接next,输入对应的 groupId,artifactId
在创建一个module,结果如下所示:
展开目录。test模块引用testSon模块。
test的pom文件如下
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.test</groupId>
<artifactId>testSon</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
testSon的pom
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>testSon</artifactId>
<version>1.0-SNAPSHOT</version>
</project>
testSon下创建Dog类
public class Dog {
public void call(String s){
System.out.println("wwwww"+s);
}
}
test下创建Animal调用
public class Animal {
public static void main(String[] args) {
Dog dog = new Dog();
dog.call("狗叫");
}
}
然后启动,可能会遇到的问题
1、IDEA中提示:Warning:java: 源值1.5已过时, 将在未来所有发行版中删除
2、Cannot start process, the working directory ‘F:\test\hello’ does not exist
问题一解决:
打开项目配置(默认快捷键:ctrl+shift+alt+s
):
打开【File】—【Settings】,找到【Java Compiler】
点击Apply—OK
问题二解决:
点击Apply—OK
之后你可能还会遇到版本问题(原因我也不知道。。。)。然后按照问题一的解决方式重新配置一下。(可能因为配置步骤,它有回到1.5了。)