Eclipse 在 wtpwebapps 中生成我的类 3 次

发布于 2024-12-10 04:26:16 字数 2336 浏览 2 评论 0原文

我有一个 PrettyFaces 框架的问题,当使用 eclipse 在服务器(tomcat 6)上运行应用程序时,多次找到一个类

,我发现 eclipse 在 wtpwebapps 中多次生成该类:

\WEB-INF\classes\com\myapp\sample\beans\myclass.class
WEB-INF\classes\target\classes\com\myapp\sample\beans\myclass.class
\WEB-INF\classes\target\app-name\WEB-INF\classes\com\myapp\sample\beans\myclass.class

更新:

我正在使用 m2eclipse 插件,并使用 ma​​ven 作为我的构建工具,也许它们的配置有问题,或者需要配置一些东西。

更新2:

这是pom文件构建,也许我有问题:有

<build>

        <finalName>appName</finalName> 

        <resources>

            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>

        </resources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>install</id>
                        <phase>install</phase>
                        <goals>
                            <goal>sources</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-resources-plugin</artifactId>
               <version>2.5</version>
               <configuration>
               <encoding>UTF-8</encoding>
               </configuration>
            </plugin>
        </plugins>
    </build>

什么想法如何解决这个问题吗?

i had an issue with PrettyFaces framework that a class is found more than once when using eclipse to run application on server (tomcat 6)

what i found is that eclipse generates the class more than once in wtpwebapps:

\WEB-INF\classes\com\myapp\sample\beans\myclass.class
WEB-INF\classes\target\classes\com\myapp\sample\beans\myclass.class
\WEB-INF\classes\target\app-name\WEB-INF\classes\com\myapp\sample\beans\myclass.class

UPDATE:

i am using m2eclipse plugin, and using maven as my build tool, maybe there's a configuration wrong with them, or something needed to be configured.

UPDATE2:

here's the pom file build, maybe i have something wrong with it:

<build>

        <finalName>appName</finalName> 

        <resources>

            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>

        </resources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>install</id>
                        <phase>install</phase>
                        <goals>
                            <goal>sources</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-resources-plugin</artifactId>
               <version>2.5</version>
               <configuration>
               <encoding>UTF-8</encoding>
               </configuration>
            </plugin>
        </plugins>
    </build>

any ideas how to fix this issue ?

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

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

发布评论

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

评论(1

前事休说 2024-12-17 04:26:16

我安装了“m2e wtp”连接器了吗? Maven->发现->打开目录(在 Indigo 中)搜索“wtp”。

考虑使用:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

那么可能不需要按照您的方式设置UTF-8。但也许此时您有另一种编码,但如果有 *.java 一种编码和另一种编码的资源,那就很奇怪了。最好使整个项目相同。

您能否确认您是否正在构建 WAR 并且这就是您在 WAR 中看到的内容?或者如果正在使用 Eclipse 的启动 Tomcat 功能,这就是您在项目中看到的内容。

另外确认你已经使用了Stop Tomcat、Clean,手动检查目录是否已经清除掉了(也许做一下工作区刷新,以及另一个Servers -> Clean,手动删除Tomcat区域中的文件)。然后执行完整发布(到 tomcat),然后启动/调试 tomcat 来启动。

我猜想如果您现在拥有的配置如上所示(并且假设没有父 pom.xml 严重影响构建),您看到的文件是在弄乱 Maven 配置后未清理 wtpwebapps 区域的结果。

有多个地方需要检查是否清洁:

Temporarly Turn off: Project -> Build Automatically
Stop All Servers instances running like: Tomcat
Run As -> Maven -> clean
Servers -> Clean

Open file browser and validate for yourself outside of Eclipse that the following dirs are empty or non-existant:

  workspaceDirectory/projectDirectory/target   (the maven output folder)

  workspaceDirectory/metadata/.plugins/org.eclipse.wst.server.core/tmpX/wtpwebapps/**
  # This one is ok to have the top level contextPath's, provind they are currently active projects you have added to the server.

  $CATALINA_HOME/

Perform workspace refresh (to ensure Eclipse resync file system state to workspace state).  I do this with clicking on any project in Project Explorer, then Ctrl-Clicking it again to deselect it (so nothing is selected but Project Explorer is in focus) then press F5.   Other people use Ctrl-A to select all projects.

  Now do a Project -> Build All
  Now do a Servers -> Publish  (now check the tree you get)

  Now re-enable Project -> Build Automatically (if you run that way)  

I have you installed the "m2e wtp" connector ? Maven -> Discovery -> Open Catalog (in Indigo) search "wtp".

Consider using:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

then there may not be any need for setting UTF-8 in the way you do. But maybe you have another encoding at this point, but then it would be strange to have *.java one encoding and resources in another. Best to make the whole project same.

Can you confirm if you are building a WAR and this is what you see in the WAR ? or if are using the launch Tomcat ability from Eclipse and this is what you see in the project.

Also confirm that you have used the Stop Tomcat, Clean, manually check the directory have cleared out (maybe do a workspace refresh, and another Servers -> Clean, manually delete files in Tomcat area). Then do a Full Publish (to tomcat) and then Start/Debug tomcat to launch.

I would guess if the configuration you now have is as above (and presuming no parent pom.xml is affecting the build do badly) that the files you see are a result of not cleaning the wtpwebapps area after messing around with the maven config.

There are multiple places to check gets cleaned:

Temporarly Turn off: Project -> Build Automatically
Stop All Servers instances running like: Tomcat
Run As -> Maven -> clean
Servers -> Clean

Open file browser and validate for yourself outside of Eclipse that the following dirs are empty or non-existant:

  workspaceDirectory/projectDirectory/target   (the maven output folder)

  workspaceDirectory/metadata/.plugins/org.eclipse.wst.server.core/tmpX/wtpwebapps/**
  # This one is ok to have the top level contextPath's, provind they are currently active projects you have added to the server.

  $CATALINA_HOME/

Perform workspace refresh (to ensure Eclipse resync file system state to workspace state).  I do this with clicking on any project in Project Explorer, then Ctrl-Clicking it again to deselect it (so nothing is selected but Project Explorer is in focus) then press F5.   Other people use Ctrl-A to select all projects.

  Now do a Project -> Build All
  Now do a Servers -> Publish  (now check the tree you get)

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