我这边想要生成一个可以运行的jar包,为此需要在pom里添加主类所在的包名,但是一直报错显示声明的包与预期的包不符,这咋解决啊
<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.0modelVersion>
<groupId>com.jellythink.HelloWorldgroupId>
<artifactId>hello-worldartifactId>
<version>1.0-SNAPSHOTversion>
<name>hello-worldname>
<properties>
<project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
<maven.compiler.release>13maven.compiler.release>
properties>
<build>
<finalName>${project.artifactId}finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-compiler-pluginartifactId>
<version>3.8.1version>
<configuration>
<archive>
<manifest>
<addClasspath>trueaddClasspath>
<mainClass>src.main.javamainClass>
manifest>
archive>
configuration>
plugin>
plugins>
pluginManagement>
build>
<dependencies>
<dependency>
<groupId>junitgroupId>
<artifactId>junitartifactId>
<version>4.11version>
<scope>testscope>
dependency>
<dependency>
<groupId>gov.nist.mathgroupId>
<artifactId>jamaartifactId>
<version>1.0.3version>
dependency>
dependencies>
project>
你用的是maven管理项目,src/main/java是java代码的源代码根目录,根据你的截图,你的main test.java不属于任何包下,所以需要把mainTest.java的第一行package src.main.java删除掉。
另外,建议类名使用大写字母开头。
另外,你的pom文件中maven-plugin的mainClass定义也是错的。
望采纳,谢谢!