当前位置: 首页 > news >正文

沧县网站制作价格快手seo

沧县网站制作价格,快手seo,个人营业执照办理网上办理,深圳市建设行业门户网站报错分析 报错原因:Maven 构建时,Java 版本配置不匹配 我安装的JDK版本是1.8,但由于种种原因,Maven构建时指定了 Java 17 作为目标发行版,从而导致错误 解决方案 首先,java -version,查看环…

报错分析

报错原因:Maven 构建时,Java 版本配置不匹配

我安装的JDK版本是1.8,但由于种种原因,Maven构建时指定了 Java 17 作为目标发行版,从而导致错误

解决方案

首先,java -version,查看环境变量是否设置为了想要的JDK版本

1.检查pom文件

由于是在Maven构建时报错,所以优先检查pom文件,查看是否在properties中设置了错误的compiler.sourcecompiler.target

如上所示则是正确的(因为使用的JDK版本是1.8)

两个参数的含义分别是:

maven.compiler.source设置为 1.8,表示使用 Java 8 的语法规则来编译源代码

maven.compiler.target设置为 1.8,表示生成的字节码版本为 Java 8

2.查看Maven的有效配置

在编译时,可以使用 maven-compiler-plugin 插件指定所使用的JDK的版本,如果没有指定的话,将会使用默认配置,可以通过mvn help:effective-pom指令来查看默认配置,打印输出的内容结构如下:

  <modelVersion>4.0.0</modelVersion><groupId>com.why</groupId><artifactId>Sort-Array-Desc</artifactId><version>1.0-SNAPSHOT</version><properties><maven.compiler.compilerVersion>17</maven.compiler.compilerVersion><maven.compiler.source>17</maven.compiler.source><maven.compiler.target>17</maven.compiler.target><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><dependencies><dependency><groupId>org.apache.hive</groupId><artifactId>hive-exec</artifactId><version>3.1.3</version><scope>compile</scope></dependency></dependencies><repositories><repository><snapshots><enabled>false</enabled></snapshots><id>central</id><name>Central Repository</name><url>https://repo.maven.apache.org/maven2</url></repository></repositories><pluginRepositories><pluginRepository><releases><updatePolicy>never</updatePolicy></releases><snapshots><enabled>false</enabled></snapshots><id>central</id><name>Central Repository</name><url>https://repo.maven.apache.org/maven2</url></pluginRepository></pluginRepositories><build><sourceDirectory>D:\codes\java\hive\Sort-Array-Desc\src\main\java</sourceDirectory><scriptSourceDirectory>D:\codes\java\hive\Sort-Array-Desc\src\main\scripts</scriptSourceDirectory><testSourceDirectory>D:\codes\java\hive\Sort-Array-Desc\src\test\java</testSourceDirectory><outputDirectory>D:\codes\java\hive\Sort-Array-Desc\target\classes</outputDirectory><testOutputDirectory>D:\codes\java\hive\Sort-Array-Desc\target\test-classes</testOutputDirectory><resources><resource><directory>D:\codes\java\hive\Sort-Array-Desc\src\main\resources</directory></resource></resources><testResources><testResource><directory>D:\codes\java\hive\Sort-Array-Desc\src\test\resources</directory></testResource></testResources><directory>D:\codes\java\hive\Sort-Array-Desc\target</directory><finalName>Sort-Array-Desc</finalName><pluginManagement><plugins><plugin><artifactId>maven-antrun-plugin</artifactId><version>1.3</version></plugin><plugin><artifactId>maven-assembly-plugin</artifactId><version>2.2-beta-5</version></plugin><plugin><artifactId>maven-dependency-plugin</artifactId><version>2.8</version></plugin><plugin><artifactId>maven-release-plugin</artifactId><version>2.5.3</version></plugin></plugins></pluginManagement><plugins><plugin><artifactId>maven-compiler-plugin</artifactId><version>3.8.1</version><executions><execution><id>default-compile</id><phase>compile</phase><goals><goal>compile</goal></goals><configuration><source>1.8</source><target>1.8</target></configuration></execution><execution><id>default-testCompile</id><phase>test-compile</phase><goals><goal>testCompile</goal></goals><configuration><source>1.8</source><target>1.8</target></configuration></execution></executions><configuration><source>1.8</source><target>1.8</target></configuration></plugin><plugin><artifactId>maven-clean-plugin</artifactId><version>2.5</version><executions><execution><id>default-clean</id><phase>clean</phase><goals><goal>clean</goal></goals></execution></executions></plugin><plugin><artifactId>maven-resources-plugin</artifactId><version>2.6</version><executions><execution><id>default-testResources</id><phase>process-test-resources</phase><goals><goal>testResources</goal></goals></execution><execution><id>default-resources</id><phase>process-resources</phase><goals><goal>resources</goal></goals></execution></executions></plugin><plugin><artifactId>maven-jar-plugin</artifactId><version>2.4</version><executions><execution><id>default-jar</id><phase>package</phase><goals><goal>jar</goal></goals></execution></executions></plugin><plugin><artifactId>maven-surefire-plugin</artifactId><version>2.12.4</version><executions><execution><id>default-test</id><phase>test</phase><goals><goal>test</goal></goals></execution></executions></plugin><plugin><artifactId>maven-install-plugin</artifactId><version>2.4</version><executions><execution><id>default-install</id><phase>install</phase><goals><goal>install</goal></goals></execution></executions></plugin><plugin><artifactId>maven-deploy-plugin</artifactId><version>2.7</version><executions><execution><id>default-deploy</id><phase>deploy</phase><goals><goal>deploy</goal></goals></execution></executions></plugin><plugin><artifactId>maven-site-plugin</artifactId><version>3.3</version><executions><execution><id>default-site</id><phase>site</phase><goals><goal>site</goal></goals><configuration><outputDirectory>D:\codes\java\hive\Sort-Array-Desc\target\site</outputDirectory><reportPlugins><reportPlugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-project-info-reports-plugin</artifactId></reportPlugin></reportPlugins></configuration></execution><execution><id>default-deploy</id><phase>site-deploy</phase><goals><goal>deploy</goal></goals><configuration><outputDirectory>D:\codes\java\hive\Sort-Array-Desc\target\site</outputDirectory><reportPlugins><reportPlugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-project-info-reports-plugin</artifactId></reportPlugin></reportPlugins></configuration></execution></executions><configuration><outputDirectory>D:\codes\java\hive\Sort-Array-Desc\target\site</outputDirectory><reportPlugins><reportPlugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-project-info-reports-plugin</artifactId></reportPlugin></reportPlugins></configuration></plugin></plugins></build><reporting><outputDirectory>D:\codes\java\hive\Sort-Array-Desc\target\site</outputDirectory></reporting>
</project>

可以看到,默认配置中,指定了源代码编译的语法规则以及生成的字节码文件版本都是Java 17,与我们本地的环境不符,因此·会报错:无效的目标发行版17

此时我很奇怪为什么默认会用Java 17的语法去进行编译,于是去查看maven的配置文件settings.xml,结果发现在<profiles></profiles>中添加了一个profile

可能是之前想要控制maven的默认编译行为,结果忘记了😂

所以解决方案有两种,第一种就是删除这里的配置,由于我所使用的maven版本是3.6.3,默认就是用Java 8 进行编译了:

第二种方法就是使用maven-compiler-plugin插件配置:

    <build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.8.1</version><configuration><source>1.8</source><target>1.8</target></configuration></plugin></plugins></build>

从而覆盖默认的配置

3.检查IDE中的JDK 配置

除了以上Maven配置的问题,我们也需要检查IDE中的配置,下述的方法在运行代码报错时同样可用

3.1 Project Structure

进入File -> Project Structure

Project标签页中,检查 Project SDK 是否设置为 1.8:

Modules 标签页中,检查 Module SDK以及language level是否设置为 1.8:

3.2 Java Compiler

进入File -> Settings -> Java Compiler,检查Target bytecode version是否设置为1…8:

http://www.ds6.com.cn/news/13517.html

相关文章:

  • 怎么查网站的关键词求职seo
  • 专做品牌的网站百度seo白皮书
  • java做网站pdfseo搜索引擎优化兴盛优选
  • wordpress密码对的登不不了昆明seo排名外包
  • 比较多人用什么网站做推广济南新闻头条最新事件
  • 网站cdn加速怎么入侵河北网络科技有限公司
  • 品牌型网站建设哪网站源码建站
  • 网站域名注册时间seo优化培训班
  • 营销网站建设工作超级外链推广
  • 系统开发者选项怎么关win7优化工具哪个好用
  • 免费做网站平台优化大师破解版app
  • 网站如何做排名seo搜索优化技术
  • 用wordpress做网站教程如何在网络上推广产品
  • 广西建设职业技术学院管理工程系网站2014考试前培训时间网站域名查询工具
  • wordpress不用模版四川seo推广方案
  • 贵州做网站的公司链接购买
  • 自己建网站有什么用百度合伙人官方网站
  • 住宅小区物业管理系统网站建设seo外包费用
  • 自己做网站网站资源哪里来营销百度app下载手机版
  • 如何用付费音乐做视频网站百家号seo
  • 卖高权重网站做跳转整合营销
  • 做策划的都上哪些网站搜索资料间网络推广怎么做好
  • 房屋 哪个网站做的最好seo工作职责
  • 揭阳网站制作机构长沙大型网站建设公司
  • 邵阳网站建设多少钱优化网站排名茂名厂商
  • 学做网站多久官网排名优化方案
  • 微网站开发平台有哪些好的百度推广助手app下载
  • 网页生成助手seo导航
  • 他达拉非能延时多久seo服务公司招聘
  • 青岛建站模板厂家网站seo排名优化软件