简体   繁体   English

春季引导战争到外部雄猫

[英]spring boot war to external tomcat

I am trying to deploy my Spring boot project on external Tomcat server. 我正在尝试在外部Tomcat服务器上部署我的Spring启动项目。 I followed all given advices here http://docs.spring.io/spring-boot/docs/1.1.4.RELEASE/reference/htmlsingle/#build-tool-plugins-maven-packaging , however i am a bit confused as i deployed it on the server and everything is ok, but i am getting 404 error every time i access any of pages. 我遵循了这里给出的所有建议http://docs.spring.io/spring-boot/docs/1.1.4.RELEASE/reference/htmlsingle/#build-tool-plugins-maven-packaging ,但是我有点困惑我将其部署在服务器上,一切正常,但是每次访问任何页面时,我都会收到404错误。 Also, i add to application.properties 另外,我添加到application.properties

server.context-path=/bqp

so i use url's like this http://128.0.169.5:8082/bqp/ 所以我使用这样的网址http://128.0.169.5:8082/bqp/

在此处输入图片说明

UPDATED: 更新:

my spring-config.xml: 我的spring-config.xml:

<context:component-scan base-package="com.bionic" />
<bean id="entityManagerFactory"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" />
    <property name="persistenceUnitName" value="com.bionic.quizzes" />
    <property name="dataSource" ref="dataSource" />
    <property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
    <property name="jpaDialect" ref="jpaDialect" />
</bean>

<bean id="jpaVendorAdapter"
      class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
    <property name="database" value="HSQL" />
    <property name="databasePlatform" value="org.hibernate.dialect.HSQLDialect" />
</bean>

<bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />

<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>

<tx:annotation-driven transaction-manager="transactionManager" />

<bean id="dataSource"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mysql://localhost:3306/quizzes" />
    <property name="username" value="root" />
    <property name="password" value="root" />
</bean>

Also, I could easy deploy it by main method of Spring boot. 另外,我可以通过Spring boot的主要方法轻松部署它。 But I should deploy it on remote server. 但是我应该将其部署在远程服务器上。

Application.class: Application.class:

@SpringBootApplication
public class DemoApplication extends SpringBootServletInitializer{

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(DemoApplication.class);
}

public static void main(String[] args) {
    SpringApplication.run(DemoApplication.class, args);
}

} }

Try put this code on your servlet.xml 尝试将此代码放在servlet.xml中

     <bean class= 
        "org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/bqp/"/>
        <property name="suffix" value=".jsp"/> //if you are using .jsp
    </bean>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM