休眠限制连接不适用于系统tomcat

时间:2019-01-20 06:37:58

标签: java eclipse hibernate tomcat

我也是论坛和Web应用程序开发的新手。我正在尝试开发一个数据库驱动的Web应用程序,在其中尝试使用Java Hibernate和PostgreSQL进行数据库事务。

我的问题是,当我通过eclipse IDE运行应用程序时,它运行良好并显示正确的结果。当我在.war文件中导出相同的应用程序并尝试通过系统的tomcat运行它时,它的工作就像所有限制一样,都希望Hibernate Conjuction。


Criteria criteria = sessionFactory.getCurrentSession()
 .createCriteria(CompleteAnnotationhg19.class);

criteria.add((Conjunction) Restrictions.and(Restrictions.eq("smarChr", chr).ignoreCase(), Restrictions.eq("smarStart", Integer.parseInt(start)), 
        Restrictions.eq("smarEnd", Integer.parseInt(end))));

POM.XML


<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.example</groupId>
    <artifactId>skeleton-web-service</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>skeleton-web-service</name>
    <url>http://maven.apache.org</url>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.2.1.RELEASE</version>
    </parent>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> 
            <scope>provided</scope> </dependency> -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20151123</version>
        </dependency>
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.2.2</version><!--$NO-MVN-MAN-VER$ -->
        </dependency>

        <!-- Hibernate -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.3.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <!-- Must override version or face stack traces -->
            <version>4.3.0.Final</version><!--$NO-MVN-MAN-VER$ -->
        </dependency>

        <!-- websocket -->

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-messaging</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-websocket</artifactId>
        </dependency>
        <!--ec1 websocket -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>net.sourceforge.nekohtml</groupId>
            <artifactId>nekohtml</artifactId>
            <version>1.9.20</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
            <version>3.3.4</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>jquery</artifactId>
            <version>2.1.4</version>
        </dependency>
        <!-- Spring ORM, works with Hibernate -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
        </dependency>

        <!-- Spring implementation of Jackson for RESTful JSON -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>

        <!-- JDBC -->
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId> 
            <version>9.4-1200-jdbc41</version>
            <!-- <groupId>postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.1-901.jdbc4</version> -->
        </dependency>
        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>2.10.4</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>
                spring-boot-starter-data-elasticsearch
            </artifactId>
        </dependency>
    </dependencies>

    <build>
        <!-- <sourceDirectory>src</sourceDirectory> -->
        <finalName>MARome</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version><!--$NO-MVN-MAN-VER$ -->
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <mainClass>${start-class}</mainClass>
                    <options>
                        <options>-keep class javax.** { *; }</options>
                        <options>-keep class org.org.springframework.** { *; }</options>
                        <options>-keep class sun.** { *; }</options>
                        <options>-keep class java.awt.** { *; }</options>
                        <option>-keepdirectories org/**</option>
                        <option>-keep public class com.jaxlayer.Application { *; }</option>
                        <option>-keep public class com.jaxlayer.webreflector.rest { *; }</option>
                        <option>-keepattributes
                            Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod</option>
                        <option>-keepclasseswithmembers public class * { public static
                            void main(java.lang.String[]);}</option>
                        <option>-keepclassmembers class * {
                            @org.springframework.beans.factory.annotation.Autowired *;
                            @org.springframework.beans.factory.annotation.Value *;
                            @org.springframework.context.annotation.Configuration *;
                            }
                        </option>
                        <options>-keep class !com.jaxlayer.webreflector.resti.** { *; }</options>
                    </options>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <warSourceDirectory>WebContent</warSourceDirectory>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

0 个答案:

没有答案