1.问题描述:
Maven 依赖必须申明在父工程pom中,若写在子工程pom,则依赖不生效>_<,求各位好大Lao解惑!需将依赖申明在子工程中并生效明
2.申明在父工程中,可正常加载依赖
2.1父工程pom截图
2.2子工程pom截图
2.3使用注解代码
3.申明在子工程中,不能正常加载依赖
3.1父工程pom截图
3.2子工程pom截图
3.3使用注解代码
4.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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.10</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.smart.classroom</groupId>
<artifactId>smart-classroom-subscription</artifactId>
<version>1.0.0</version>
<name>smart-classroom-subscription</name>
<description>smart-classroom-subscription</description>
<properties>
<java.version>1.8</java.version>
</properties>
<modules>
<module>scs-utility</module>
</modules>
</project>
<?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">
<parent>
<artifactId>smart-classroom-subscription</artifactId>
<groupId>com.smart.classroom</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>scs-utility</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<!-- *********************工具库 start********************* -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!-- *********************工具库 end********************* -->
</dependencies>
</project>
import lombok.Getter;
public enum SortDirection {
ASC("升序"),
DESC("降序");;
@Getter
private final String description;
SortDirection(String description) {
this.description = description;
}
public static String toString(SortDirection orderStatus) {
if (orderStatus == null) {
return null;
}
return orderStatus.name();
}
public static SortDirection toEnum(String s) {
if (s == null) {
return null;
}
return SortDirection.valueOf(s);
}
}