序言
在传统Java开发项目中,我们可以利用Maven来管理jar包依赖,但在mendix项目开发Custom Java Action
时,由于目录结构有一些差异,我们需要自行配置。
完整示例
https://gitee.com/engalar/mendix-debugger-demo
配置文件
{项目目录}/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/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.wanma</groupId> <artifactId>albert_mendix_blog_9</artifactId> <version>1.0.0</version> <properties> <hutool.version>5.8.16</hutool.version> </properties> <dependencies> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>${hutool.version}</version> </dependency> <!-- 此处添加你需要的jar包依赖 --> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>3.0.1</version> <executions> <execution> <id>copy-dependencies</id> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.basedir}/userlib</outputDirectory> <overWriteReleases>false</overWriteReleases> <overWriteSnapshots>false</overWriteSnapshots> <overWriteIfNewer>true</overWriteIfNewer> <excludeGroupIds>com.mendix</excludeGroupIds> </configuration> </execution> </executions> </plugin> </plugins> </build> <pluginRepositories> <pluginRepository> <id>aliyun-plugin</id> <url>https://maven.aliyun.com/repository/central</url> </pluginRepository> </pluginRepositories> <repositories> <repository> <id>aliyun-central</id> <name>aliyun central</name> <url>https://maven.aliyun.com/repository/central</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> </project>
接下来我们只需要把我们项目的依赖填入即可,如
<dependencies> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.8.16</version> </dependency> <!-- 此处添加你需要的jar包依赖 --> </dependencies>
执行依赖安装
#mvn clean mvn compile