0

我无法理解缺少什么/要安装什么才能在 cmd 中编译我的代码。它在 IntelliJ IDE 中工作,我看到过类似的问题,但无法掌握有关使用“胖罐子”和 maven 依赖项的答案。

ain.java:1: error: package com.googlecode.lanterna.graphics does not exist
import com.googlecode.lanterna.graphics.TextGraphics;
                                       ^
Main.java:2: error: package com.googlecode.lanterna.screen does not exist
import com.googlecode.lanterna.screen.Screen;
                                     ^
Main.java:3: error: package com.googlecode.lanterna.screen does not exist
import com.googlecode.lanterna.screen.TerminalScreen;
                                     ^
Main.java:4: error: package com.googlecode.lanterna.terminal does not exist
import com.googlecode.lanterna.terminal.DefaultTerminalFactory;
                                       ^
Main.java:5: error: package com.googlecode.lanterna.terminal does not exist
import com.googlecode.lanterna.terminal.Terminal;
                                       ^
Main.java:6: error: package com.googlecode.lanterna.terminal.virtual does not exist
import com.googlecode.lanterna.terminal.virtual.DefaultVirtualTerminal;

这是 pom.xml

<?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>at.htl</groupId>
    <artifactId>lanternademo</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <dependencies>
        <dependency>
            <groupId>com.googlecode.lanterna</groupId>
            <artifactId>lanterna</artifactId>
            <version>3.1.1</version>
        </dependency>
    </dependencies>

    <properties>
        <maven.compiler.source>16</maven.compiler.source>
        <maven.compiler.target>16</maven.compiler.target>
    </properties>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>3.1.0</version>
        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                    <goal>shade</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

</project>
4

1 回答 1

0

像 IntelliJ 这样的 IDE 会为您完成大量编译和收集工作,但默认情况下,使用库的已编译类不会编译它们正在使用的库。为了实现这一点,您将不得不使用类似 jar-with-dependencies 之类的东西,我会向您推荐这个线程:如何使用 Maven 创建具有依赖关系的可执行 JAR?

于 2021-05-22T19:39:22.803 回答