Tôi đang cố gắng thực hiện một vài tác vụ với plugin trình quản lý maven. Một là chạy một kịch bản để tạo ra một số dữ liệu bên ngoài mà ứng dụng sẽ sử dụng. Thứ hai là chạy một đoạn mã java để thực hiện một số công việc tiện lợi trong giai đoạn biên dịch.Bạn có thể xác định cả mục tiêu exec và java cho plugin maven exec không?
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>data_for_app</id>
<phase>generate-sources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${basedir}/scripts/getappdata.sh</executable>
<arguments>
<argument>${basedir}/src/main/webapp/WEB-INF/xml/appdatahere/</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>do_convenience</id>
<phase>compile</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>com.example.DoConvenienceStuff</mainClass>
<arguments>
<argument>https://example.com/data</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
Nhưng khi tôi chạy:
mvn clean package exec:exec
tôi nhận được lỗi:
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project jss: The parameters 'executable' for goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec are missing or invalid -> [Help 1]
Hoặc một lỗi tương tự nói tham số 'mainClass' bị thiếu hoặc không hợp lệ.
Cảm ơn bạn đã chỉ ra rằng nó không hoạt động để nói 'mvn exec: exec' - điều này không rõ ràng với tôi ngay cả sau khi đọc tài liệu cũng như một số câu trả lời khác trên SO! –