Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在eclipse中导入maven EJB项目?(不含m2e)_Java_Eclipse_Jakarta Ee_Maven_Ejb 3.0 - Fatal编程技术网

Java 如何在eclipse中导入maven EJB项目?(不含m2e)

Java 如何在eclipse中导入maven EJB项目?(不含m2e),java,eclipse,jakarta-ee,maven,ejb-3.0,Java,Eclipse,Jakarta Ee,Maven,Ejb 3.0,我通过Maven使用“org.codehaus.mojo.archetypes:EJB-jee5”最新版本创建了一个EJB项目 然后我键入“mvn安装”和“mvn eclipse:eclipse” 最后,我在eclipse中将其作为一个通用java项目导入,但该项目没有被认可为支持EJB 我做错了什么 谢谢 编辑 按照awnser的建议尝试了这个,但不起作用 <build> <plugins> <plugin>

我通过Maven使用“org.codehaus.mojo.archetypes:EJB-jee5”最新版本创建了一个EJB项目

然后我键入“mvn安装”和“mvn eclipse:eclipse”

最后,我在eclipse中将其作为一个通用java项目导入,但该项目没有被认可为支持EJB

我做错了什么

谢谢

编辑 按照awnser的建议尝试了这个,但不起作用

<build>
    <plugins>   
        <plugin>
            <artifactId>maven-eclipse-plugin</artifactId>
            <configuration>
                <buildcommands>
                    <buildcommand>org.eclipse.wst.common.project.facet.core.builder</buildcommand>
                    <buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
                    <buildcommand>org.eclipse.wst.validation.validationbuilder</buildcommand>
                </buildcommands>
                <additionalProjectnatures>
                    <projectnature>org.eclipse.jem.workbench.JavaEMFNature</projectnature>
                    <projectnature>org.eclipse.wst.common.modulecore.ModuleCoreNature</projectnature>
                    <projectnature>eclipse.jdt.core.javanature</projectnature>
                    <projectnature>org.eclipse.wst.common.project.facet.core.nature</projectnature>
                </additionalProjectnatures>
            </configuration>
        </plugin>
    </plugins>
</build>

maven eclipse插件
org.eclipse.wst.common.project.facet.core.builder
org.eclipse.jdt.core.javabuilder
org.eclipse.wst.validation.validationbuilder
org.eclipse.jem.workbench.JavaEMFNature
org.eclipse.wst.common.modulecore.ModuleCoreNature
eclipse.jdt.core.javanature
org.eclipse.wst.common.project.facet.core.nature
编辑 显然,将这些生成器和属性添加到.project中并不是很简单,还必须生成一个描述启用了哪个方面的xml文件,为此,我应该在“”标记之间添加以下代码


1.6
3

但是,这4行代码会生成一个“构建失败”

您可以在pom.xml中添加所需的性质(在eclipse world中就是这样命名的)


请参阅创建一个空的EJB项目,并在.project中查看该属性的命名方式(它可能有多个属性)。

因此我发现,正如预期的那样,修改项目属性是不够的,您还必须生成其他文件来描述诸如激活的方面等内容

将它添加到EJB项目中,它将被识别为没有m2e的EJB

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-eclipse-plugin</artifactId>
                <configuration>
                    <additionalBuildcommands>
                        <buildCommand>
                            <name>org.eclipse.jdt.core.javabuilder</name>
                        </buildCommand>
                        <buildCommand>
                            <name>org.eclipse.wst.common.project.facet.core.builder</name>
                        </buildCommand>
                        <buildCommand>
                            <name>org.eclipse.wst.validation.validationbuilder</name>
                        </buildCommand>
                        <buildCommand>
                            <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
                            <arguments>
                                <LaunchConfigHandle>&lt;project&gt;/.settings/MavenBuilder.launch</LaunchConfigHandle>
                            </arguments>
                        </buildCommand>
                    </additionalBuildcommands>
                    <additionalProjectnatures>
                        <projectnature>org.eclipse.wst.common.project.facet.core.nature</projectnature>
                        <projectnature>org.eclipse.jdt.core.javanature</projectnature>
                        <projectnature>org.eclipse.wst.common.modulecore.ModuleCoreNature</projectnature>
                        <projectnature>org.eclipse.jem.workbench.JavaEMFNature</projectnature>
                    </additionalProjectnatures>
                    <additionalConfig>
                        <file>
                            <name>.settings/org.eclipse.wst.common.project.facet.core.xml</name>
                            <content>
                                <![CDATA[<faceted-project>
    <runtime name="my JBoss Runtime" />
    <fixed facet="jst.ejb" />
    <fixed facet="jst.java" />
    <installed facet="jst.java" version="6.0" />
    <installed facet="jst.ejb" version="3.0" />
</faceted-project>]]>
                            </content>
                        </file>
                        <file>
                            <name>.settings/org.eclipse.wst.common.component</name>
                            <content>
                                <![CDATA[
<project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="${project.artifactId}">
        <wb-resource deploy-path="/" source-path="/src/main/java" />
        <wb-resource deploy-path="/" source-path="/src/main/resources" />
        <property name="java-output-path" value="target/classes" />
    </wb-module>
</project-modules>]]>
                            </content>
                        </file>
                        <file>
                            <name>.checkstyle</name>
                            <content>
                                <![CDATA[<fileset-config file-format-version="1.2.0" simple-config="true">
    <fileset name="all" enabled="true" check-config-name="Myproject Checks" local="false">
        <file-match-pattern match-pattern="." include-pattern="true" />
    </fileset>
</fileset-config>]]>
                            </content>
                        </file>
                        <file>
                            <name>.settings/MavenBuilder.launch</name>
                            <content>
                                <![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="$${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;launchConfigurationWorkingSet editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot; factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; label=&quot;working set&quot; name=&quot;working set&quot;&gt;&#13;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/acces-services/target/test-classes&quot; type=&quot;2&quot;/&gt;&#13;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/acces-services/target/classes&quot; type=&quot;2&quot;/&gt;&#13;&#10;&lt;/launchConfigurationWorkingSet&gt;}" />
<booleanAttribute key="org.eclipse.debug.core.capture_output" value="false" />
<booleanAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON" value="false" />
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false" />
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="$${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;launchConfigurationWorkingSet editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot; factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; label=&quot;workingSet&quot; name=&quot;workingSet&quot;&gt;&#13;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/acces-services/src/test/resources&quot; type=&quot;2&quot;/&gt;&#13;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/acces-services/src/main/resources&quot; type=&quot;2&quot;/&gt;&#13;&#10;&lt;/launchConfigurationWorkingSet&gt;}" />
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${env.M2_HOME}\bin\mvn.bat" />
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,clean" />
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="resources:resources resources:testResources --offline" />
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true" />
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="$${workspace_loc:/acces-services}" />
</launchConfiguration>]]>
                            </content>
                        </file>
                    </additionalConfig>
                </configuration>
            </plugin>
        </plugins>
    </build>

maven eclipse插件
org.eclipse.jdt.core.javabuilder
org.eclipse.wst.common.project.facet.core.builder
org.eclipse.wst.validation.validationbuilder
org.eclipse.ui.externaltools.ExternalToolBuilder
project/.settings/MavenBuilder.launch
org.eclipse.wst.common.project.facet.core.nature
org.eclipse.jdt.core.javanature
org.eclipse.wst.common.modulecore.ModuleCoreNature
org.eclipse.jem.workbench.JavaEMFNature
.settings/org.eclipse.wst.common.project.facet.core.xml
]]>
.settings/org.eclipse.wst.common.component
]]>
.方格
]]>
.settings/MavenBuilder.launch
]]>

请注意,我们正在定义正在使用的服务器运行时,这意味着您必须在之前配置服务器运行时,并将其名称放入其中。

我编辑了我的问题,向您展示了我放入pom.xml中的代码,但实际上,它不起作用。
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-eclipse-plugin</artifactId>
                <configuration>
                    <additionalBuildcommands>
                        <buildCommand>
                            <name>org.eclipse.jdt.core.javabuilder</name>
                        </buildCommand>
                        <buildCommand>
                            <name>org.eclipse.wst.common.project.facet.core.builder</name>
                        </buildCommand>
                        <buildCommand>
                            <name>org.eclipse.wst.validation.validationbuilder</name>
                        </buildCommand>
                        <buildCommand>
                            <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
                            <arguments>
                                <LaunchConfigHandle>&lt;project&gt;/.settings/MavenBuilder.launch</LaunchConfigHandle>
                            </arguments>
                        </buildCommand>
                    </additionalBuildcommands>
                    <additionalProjectnatures>
                        <projectnature>org.eclipse.wst.common.project.facet.core.nature</projectnature>
                        <projectnature>org.eclipse.jdt.core.javanature</projectnature>
                        <projectnature>org.eclipse.wst.common.modulecore.ModuleCoreNature</projectnature>
                        <projectnature>org.eclipse.jem.workbench.JavaEMFNature</projectnature>
                    </additionalProjectnatures>
                    <additionalConfig>
                        <file>
                            <name>.settings/org.eclipse.wst.common.project.facet.core.xml</name>
                            <content>
                                <![CDATA[<faceted-project>
    <runtime name="my JBoss Runtime" />
    <fixed facet="jst.ejb" />
    <fixed facet="jst.java" />
    <installed facet="jst.java" version="6.0" />
    <installed facet="jst.ejb" version="3.0" />
</faceted-project>]]>
                            </content>
                        </file>
                        <file>
                            <name>.settings/org.eclipse.wst.common.component</name>
                            <content>
                                <![CDATA[
<project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="${project.artifactId}">
        <wb-resource deploy-path="/" source-path="/src/main/java" />
        <wb-resource deploy-path="/" source-path="/src/main/resources" />
        <property name="java-output-path" value="target/classes" />
    </wb-module>
</project-modules>]]>
                            </content>
                        </file>
                        <file>
                            <name>.checkstyle</name>
                            <content>
                                <![CDATA[<fileset-config file-format-version="1.2.0" simple-config="true">
    <fileset name="all" enabled="true" check-config-name="Myproject Checks" local="false">
        <file-match-pattern match-pattern="." include-pattern="true" />
    </fileset>
</fileset-config>]]>
                            </content>
                        </file>
                        <file>
                            <name>.settings/MavenBuilder.launch</name>
                            <content>
                                <![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="$${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;launchConfigurationWorkingSet editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot; factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; label=&quot;working set&quot; name=&quot;working set&quot;&gt;&#13;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/acces-services/target/test-classes&quot; type=&quot;2&quot;/&gt;&#13;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/acces-services/target/classes&quot; type=&quot;2&quot;/&gt;&#13;&#10;&lt;/launchConfigurationWorkingSet&gt;}" />
<booleanAttribute key="org.eclipse.debug.core.capture_output" value="false" />
<booleanAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON" value="false" />
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false" />
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="$${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;launchConfigurationWorkingSet editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot; factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; label=&quot;workingSet&quot; name=&quot;workingSet&quot;&gt;&#13;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/acces-services/src/test/resources&quot; type=&quot;2&quot;/&gt;&#13;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/acces-services/src/main/resources&quot; type=&quot;2&quot;/&gt;&#13;&#10;&lt;/launchConfigurationWorkingSet&gt;}" />
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${env.M2_HOME}\bin\mvn.bat" />
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,clean" />
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="resources:resources resources:testResources --offline" />
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true" />
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="$${workspace_loc:/acces-services}" />
</launchConfiguration>]]>
                            </content>
                        </file>
                    </additionalConfig>
                </configuration>
            </plugin>
        </plugins>
    </build>