mvn compile编译成功了,但是找不到class文件
<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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.imooc.app</groupId> <artifactId>hellomaven</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>hellomaven</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>4.0.0</version> <scope>provided</scope> </dependency> </dependencies> </project>
之前直接从jar包里拷过来的pom.xml文件编译失败,所以从别人的问答里拷了一个老师的回答文件就是上面的,编译虽然成功了,但在target里找不到class文件,另我用的mavn是最新版本,不知道有没有关系
7
收起
正在回答
4回答
根据报错信息来看,是jdk版本太低导致的,同学的电脑中安装了几个jdk?建议在pom文件中加上如下代码试一试,祝学习愉快~
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.9</maven.compiler.source> <maven.compiler.target>1.9</maven.compiler.target> </properties>
幕之内
2018-09-14 10:04:39
D:\Program Files\apache-hellomaven>mvn compile [INFO] Scanning for projects... [INFO] [INFO] ----------------------< com.imooc.app:hellomaven >---------------------- [INFO] Building hellomaven 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ hellomaven --- [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ hellomaven --- [INFO] Changes detected - recompiling the module! [WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent! [INFO] Compiling 1 source file to D:\Program Files\apache-hellomaven\target\classes [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] 不再支持源选项 1.5。请使用 1.6 或更高版本。 [ERROR] 不再支持目标选项 1.5。请使用 1.6 或更高版本。 [INFO] 2 errors [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.973 s [INFO] Finished at: 2018-09-14T10:02:49+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project hellomaven: Compilation failure: Compilation failure: [ERROR] 不再支持源选项 1.5。请使用 1.6 或更高版本。 [ERROR] 不再支持目标选项 1.5。请使用 1.6 或更高版本。 [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException D:\Program Files\apache-hellomaven>
按照老师的先mvn clean,然后再编译,失败了,我的项目包里是有java文件的
幕之内
2018-09-13 19:15:24
D:\Program Files\apache-hellomaven>mvn compile [INFO] Scanning for projects... [INFO] [INFO] ----------------------< com.imooc.app:hellomaven >---------------------- [INFO] Building hellomaven 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ hellomaven --- [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ hellomaven --- [INFO] Nothing to compile - all classes are up to date [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.783 s [INFO] Finished at: 2018-09-13T19:13:38+08:00 [INFO] ------------------------------------------------------------------------ D:\Program Files\apache-hellomaven>
jdk1.9,然后mavn是3.5.4的
Java数据库开发与实战应用2018版
- 参与学习 人
- 提交作业 277 份
- 解答问题 4297 个
Java数据库开发的必备技能,从流行的MySQL数据库开始,到Java原生的数据库管理接口JDBC的使用,再到常用的数据持久化框架MyBatis,让你向Java工程师的目标又迈进了一步!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星