如何在Glassfish 4.1.1上部署Spring启动应用程序

时间:2015-10-12 14:12:57

标签: maven glassfish spring-boot glassfish-4

我试图在GlassFish 4.1.1上部署Spring Boot应用程序,但无法这样做。我在这里看过很多关于类似问题的帖子,但是他们似乎都没有发布适用于我的解决方法。我的pom看起来像这样

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>LetsFigureThis</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.2.6.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.7</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-batch</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-mongodb</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>4.1.7.RELEASE</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <warName>demo</warName>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.glassfish.maven.plugin</groupId>
                <artifactId>maven-glassfish-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <glassfishDirectory>C:\dev\tools\servers\glassfish4\glassfish</glassfishDirectory>
                    <user>admin</user>
                    <!--<adminPassword>admin</adminPassword>-->
                    <passwordFile>C:\dev\tools\servers\glassfish4\glassfish\passwordFile.txt</passwordFile>
                    <domain>
                        <name>domain1</name>
                        <httpPort>8080</httpPort>
                        <adminPort>4848</adminPort>
                    </domain>
                    <components>
                        <component>
                            <name>demo</name>
                            <!--<force>true</force>-->
                            <artifact>target/demo.war</artifact>
                        </component>
                    </components>
                    <debug>true</debug>
                    <terse>false</terse>
                    <echo>true</echo>

                </configuration>
            </plugin>
        </plugins>

    </build>

</project>

我已经排除了tomcat嵌入jar文件,因为它与来自GlassFish的jar冲突,我还添加了Spring Batch,因为glassfish抱怨那些丢失的。当我使用此配置部署到glassfish时,我的应用程序将使用以下日志信息进行部署

[2015-10-12T09:07:29.583-0500] [glassfish 4.1] [SEVERE] [] [global] [tid: _ThreadID=145 _ThreadName=admin-listener(10)] [timeMillis: 1444658849583] [levelValue: 1000] [[
  Class [ Lgroovy/text/markup/MarkupTemplateEngine; ] not found. Error while loading [ class org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAutoConfiguration$GroovyMarkupConfiguration ]]]

[2015-10-12T09:07:29.591-0500] [glassfish 4.1] [INFO] [] [global] [tid: _ThreadID=145 _ThreadName=admin-listener(10)] [timeMillis: 1444658849591] [levelValue: 800] [[
  Exception java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy encountered while processing annotaton for element class org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration. Message is: sun.reflect.annotation.TypeNotPresentExceptionProxy. Ignoring annotations and proceeding.]]

[2015-10-12T09:07:29.594-0500] [glassfish 4.1] [SEVERE] [] [global] [tid: _ThreadID=145 _ThreadName=admin-listener(10)] [timeMillis: 1444658849594] [levelValue: 1000] [[
  Class [ com/samskivert/mustache/Mustache$Collector ] not found. Error while loading [ class org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration ]]]

[2015-10-12T09:07:29.597-0500] [glassfish 4.1] [SEVERE] [] [global] [tid: _ThreadID=145 _ThreadName=admin-listener(10)] [timeMillis: 1444658849597] [levelValue: 1000] [[
  Class [ org/apache/solr/client/solrj/SolrServer ] not found. Error while loading [ class org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration ]]]

[2015-10-12T09:07:29.602-0500] [glassfish 4.1] [INFO] [] [global] [tid: _ThreadID=145 _ThreadName=admin-listener(10)] [timeMillis: 1444658849602] [levelValue: 800] [[
  Exception java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy encountered while processing annotaton for element class org.springframework.boot.autoconfigure.velocity.VelocityAutoConfiguration. Message is: sun.reflect.annotation.TypeNotPresentExceptionProxy. Ignoring annotations and proceeding.]]

[2015-10-12T09:07:29.631-0500] [glassfish 4.1] [SEVERE] [] [global] [tid: _ThreadID=145 _ThreadName=admin-listener(10)] [timeMillis: 1444658849631] [levelValue: 1000] [[
  Class [ org/thymeleaf/resourceresolver/IResourceResolver ] not found. Error while loading [ class org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$DefaultTemplateResolverConfiguration ]]]

[2015-10-12T09:07:29.649-0500] [glassfish 4.1] [SEVERE] [] [global] [tid: _ThreadID=145 _ThreadName=admin-listener(10)] [timeMillis: 1444658849649] [levelValue: 1000] [[
  Class [ org/flywaydb/core/Flyway ] not found. Error while loading [ class org.springframework

.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration ]]]

从日志文件中我也看到应用程序已正确部署,但是当我查找资源http://localhost:8080/demp/hello时,出现404错误。当我将我的应用程序部署为Spring Boot应用程序时,我可以毫无问题地访问我的资源。

注意:不是

的副本

http://stackoverflow.com/questions/29431579/spring-boot-app-does-not-deploy-on-glassfish-4-1

因为在我的情况下没有web.xml。部署到Servlet 3.0容器,因此所有配置都是使用代码完成的,我的设置中没有web.xml来应用上面帖子中提到的变通方法
此帖也讨论了在GlassFish 4.1上的部署,但是在4.1.1上。该帖子带有一个链接java.net/jira/browse/GLASSFISH-21265,其中提到此错误已在4.1.1中修复

非常感谢任何帮助

由于 凯

0 个答案:

没有答案