使用maven2使用jdk1.5编译项目

发布于 2024-07-23 05:42:21 字数 1191 浏览 2 评论 0原文

我设法使用 maven2 创建我的项目结构。 但是当我使用 mvn install 编译我的项目时 出现错误 -source 1.3 不支持泛型,

用 google 搜索使用 jdk1.5 构建我的项目并添加了构建标签

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.myProject</groupId>
  <artifactId>project</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>myapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
   <plugins>
       <plugin>
           <groupId>com.myProject</groupId>
           <artifactId>project</artifactId>
           <configuration>
               <source>1.5</source>
               <target>1.5</target>
           </configuration>
       </plugin>
     <plugins>
  </build>
</project>

,但这不起作用。

有什么提示吗?

i managed to create my project structure using maven2.
but when am compiling my project using mvn install
getting error
generics are not supported in -source 1.3

googled to build my project using jdk1.5 and added build tag

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.myProject</groupId>
  <artifactId>project</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>myapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
   <plugins>
       <plugin>
           <groupId>com.myProject</groupId>
           <artifactId>project</artifactId>
           <configuration>
               <source>1.5</source>
               <target>1.5</target>
           </configuration>
       </plugin>
     <plugins>
  </build>
</project>

but this is not working.

Any hints?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挽清梦 2024-07-30 05:42:21

将 maven-compiler-plugin 添加到您的构建中:

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

Add the maven-compiler-plugin to your build:

<build>
  <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.0.2</version>
    <configuration>
        <source>1.5</source>
        <target>1.5</target>
    </configuration>
    </plugin>
  </plugins>
</build>
秋心╮凉 2024-07-30 05:42:21

有一种“更简单”的方法可以完成此任务,而无需将相同的代码片段粘贴到整个模块中。 您可以设置一个反应器,然后从所有其他模块引用它,如下所示:

  <parent>
    <groupId>com.foo.bar</groupId>
    <artifactId>reactor</artifactId>    
    <version>1.0-SNAPSHOT</version>
  </parent>

在反应器的 pom 文件中,您必须放置以下内容:

<packaging>pom</packaging>

让 Maven 知道它不是 jar/war 等。

希望如此帮助

There's an "easier" way to accomplish this, without having to paste the same snippet all over your modules. You can set up a reactor and then you refer to it from all the other modules, like this:

  <parent>
    <groupId>com.foo.bar</groupId>
    <artifactId>reactor</artifactId>    
    <version>1.0-SNAPSHOT</version>
  </parent>

In the pom file of your reactor you have to put this:

<packaging>pom</packaging>

To let maven know that it's not a jar/war, etc.

Hope it helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文