找不到或无法加载主类 ide 正常执行,但是打包jar后报错 maven 引入本地包
错误: 找不到或无法加载主类 com.myali.TTSmy
问题原因: ide中编译能找到相关包,但是,打包成jar时,本地的jar引入失败
maven将系统用到的包从线上maven仓库下载到本地的maven目录;
那么我们手动将jar包按照路径格式放入maven的本地仓库目录即可
然后按照“从远程仓库的调用方式”,写入pom即可;
Java SDK_语音合成(TTS)_智能语音交互-阿里云 https://help.aliyun.com/document_detail/30431.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | <?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>MyGid</groupId> <artifactId>MyAid</artifactId> <version> 1.0 . 0 </version> <dependencies> <!--<dependency>--> <!--<groupId>com.alibaba.idst</groupId>--> <!--<artifactId>nls-service-sdk</artifactId>--> <!--<version>${project.version}</version>--> <!--<scope>system</scope>--> <!--<systemPath>${project.basedir}/lib/nls-service-sdk- 1.0 . 0 .jar</systemPath>--> <!--</dependency>--> <dependency> <groupId>com.alibaba.idst</groupId> <artifactId>nls</artifactId> <version> 1.0 . 0 </version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version> 1.2 . 26 </version> </dependency> <!-- ============================================== --> <!-- websocket netty 实现 --> <!-- ============================================== --> <dependency> <groupId>io.netty</groupId> <artifactId>netty</artifactId> <version> 3.7 . 0 .Final</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version> 3.8 . 2 </version> <scope>test</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version> 1.7 . 21 </version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version> 1.7 . 21 </version> </dependency> <!-- https: //mvnrepository.com/artifact/org.jboss/jboss-common-core --> <dependency> <groupId>org.jboss</groupId> <artifactId>jboss-common-core</artifactId> <version> 2.5 . 0 .Final</version> </dependency> </dependencies> <build> <!--使用的插件列表--> <plugins> <!--将依赖的资源全部打入lib目录--> <!--<plugin>--> <!--<groupId>org.apache.maven.plugins</groupId>--> <!--<artifactId>maven-dependency-plugin</artifactId>--> <!--<configuration>--> <!--<outputDirectory>${project.build.directory}/lib</outputDirectory>--> <!--<excludeTransitive> false </excludeTransitive>--> <!--<stripVersion> false </stripVersion>--> <!--</configuration>--> <!--<executions>--> <!--<execution>--> <!--<id>copy-dependencies</id>--> <!--<phase> package </phase>--> <!--<goals>--> <!--<goal>copy-dependencies</goal>--> <!--</goals>--> <!--<configuration>--> <!--<outputDirectory>${project.build.directory}/lib</outputDirectory>--> <!--<excludeTransitive> false </excludeTransitive>--> <!--<stripVersion> false </stripVersion>--> <!--</configuration>--> <!--</execution>--> <!--</executions>--> <!--</plugin>--> <!--Maven引入本地依赖Jar到可执行Jar包中 | IT草根 http: //www.codepub.cn/2017/06/13/Maven-introduces-local-dependency-jar-to-executable-jar-packages/--> <!--打包插件,在Jar包中添加Class-Path和Main-Class--> <!--<plugin>--> <!--<groupId>org.apache.maven.plugins</groupId>--> <!--<artifactId>maven-jar-plugin</artifactId>--> <!--<version> 3.0 . 2 </version>--> <!--<configuration>--> <!--<archive>--> <!--<!–使用自己的Manifest文件,运行正常–>--> <!--<!–<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>–>--> <!--<!–使用插件添加的Manifest文件,运行正常,一定要注意Manifest中jar包名称和lib文件夹下jar包名称版本号后缀等一定要一致,否则找不到依赖jar,此处有坑–>--> <!--<manifest>--> <!--<addClasspath> true </addClasspath>--> <!--<!–指定依赖资源路径前缀–>--> <!--<classpathPrefix>lib/</classpathPrefix>--> <!--<mainClass>com.mycom.TTSmy</mainClass>--> <!--</manifest>--> <!--<!–可以把依赖本地系统的Jar包加入Manifest文件中–>--> <!--<manifestEntries>--> <!--<Class-Path>lib/nls-service-sdk- 1.0 . 0 .jar</Class-Path>--> <!--</manifestEntries>--> <!--</archive>--> <!--</configuration>--> <!--</plugin>--> <!--idea打包jar的多种方式 - byhieg - 博客园 https: //www.cnblogs.com/qifengshi/p/6036870.html--> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version> 2.4 </version> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <archive> <manifest> <mainClass>com.mycom.TTSmy</mainClass> </manifest> </archive> </configuration> <executions> <execution> <id>make-assembly</id> <phase> package </phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source> 1.8 </source> <target> 1.8 </target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <addClasspath> true </addClasspath> <useUniqueVersions> false </useUniqueVersions> <classpathPrefix>lib/</classpathPrefix> <mainClass>com.alibaba.idst.nls.producing.TTS</mainClass> </manifest> </archive> </configuration> </plugin> </plugins> <!--Maven中使用本地JAR包 - RichardJing - 博客园 https: //www.cnblogs.com/richard-jing/archive/2013/01/27/Maven_localjar.html--> <!--<dependency>--> <!--<groupId>com.alibaba.idst</groupId>--> <!--<artifactId>nls-service-sdk</artifactId>--> <!--<version>${project.version}</version>--> <!--<scope>system</scope>--> <!--<systemPath>${project.basedir}/lib/nls-service-sdk- 1.0 . 0 .jar</systemPath>--> <!--</dependency>--> </build> </project> |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
2017-06-13 peewee sqlalchemy
2017-06-13 Python的交互模式和直接运行.py文件有什么区别