小编gre*_*old的帖子

hibernate与c3p0:createClob()尚未实现

在我的项目中,我开始使用c3p0和hibernate重新连接到数据库,因为hibernate不会在db失败时恢复连接.

<dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-c3p0</artifactId>
            <version>5.2.9.Final</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

我正在使用hibernate版本:

<dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.2.9.Final</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

postgresql驱动程序是:

<dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.1.4</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

c3p0配置是:

 properties.put("hibernate.c3p0.preferredTestQuery","SELECT 1");
    properties.put("hibernate.c3p0.testConnectionOnCheckout","true");
    properties.put("hibernate.c3p0.acquireRetryAttempts","1");
    properties.put("hibernate.c3p0.acquireIncrement","1");
    properties.put("hibernate.c3p0.idleConnectionTestPeriod","60");
Run Code Online (Sandbox Code Playgroud)

但我一直收到这个错误:

18:25:32.910 [localhost-startStop-1] DEBUG c.m.v2.c3p0.impl.NewPooledConnection - com.mchange.v2.c3p0.impl.NewPooledConnection@755e3afe handling a throwable.
java.sql.SQLFeatureNotSupportedException: Method org.postgresql.jdbc.PgConnection.createClob() is not yet implemented.
    at org.postgresql.Driver.notImplemented(Driver.java:669) ~[postgresql-42.1.4.jar:42.1.4]
    at org.postgresql.jdbc.PgConnection.createClob(PgConnection.java:1246) ~[postgresql-42.1.4.jar:42.1.4]
    at com.mchange.v2.c3p0.impl.NewProxyConnection.createClob(NewProxyConnection.java:1408) ~[c3p0-0.9.5.2.jar:0.9.5.2]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
    at org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl.useContextualLobCreation(LobCreatorBuilderImpl.java:113) [hibernate-core-5.2.9.Final.jar:5.2.9.Final]
    at org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl.makeLobCreatorBuilder(LobCreatorBuilderImpl.java:54) [hibernate-core-5.2.9.Final.jar:5.2.9.Final]
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentImpl.<init>(JdbcEnvironmentImpl.java:271) [hibernate-core-5.2.9.Final.jar:5.2.9.Final]
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:114) [hibernate-core-5.2.9.Final.jar:5.2.9.Final]
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) …
Run Code Online (Sandbox Code Playgroud)

java postgresql hibernate c3p0

16
推荐指数
2
解决办法
1万
查看次数

即使没有noarg插件,也没有Kotlin的JPA实体的默认构造函数

我已经读到您需要实体类的kotlin-maven-noarg编译器插件,以便它生成默认参数少的cosntructor。

但是应用程序未启动并出现以下错误:

没有实体的默认构造函数

你能告诉我我在做什么错吗?

pom.xml:

    <?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>
    {...}
    <build>
        <sourceDirectory>src/main/java</sourceDirectory>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>

        <testSourceDirectory>src/test/java</testSourceDirectory>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <version>${kotlin.version}</version>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>testCompile</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin> …
Run Code Online (Sandbox Code Playgroud)

spring intellij-idea kotlin

7
推荐指数
1
解决办法
2519
查看次数

向Spring Boot嵌入式tomcat添加战争

我有一个spring-boot 2.1.2.RELEASE应用程序,该应用程序使用嵌入式tomcat Web服务器并通过其SDK 使用OpenKM

现在,我有一些集成测试,这些测试使用restassuredlib进行REST调用并验证响应结构。我的想法是将其集成OpenKM.war到此嵌入式tomcat中,并能够运行此测试,而无需在其他服务器上运行openkm应用程序。

这就是我使嵌入式tomcat读取和部署openkm.war的方式:

@Configuration
public class TomcatConfig {
    @Bean
    public ServletWebServerFactory servletContainer() {
        TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory() {
            @Override
            protected void postProcessContext(Context context) {
                SecurityConstraint securityConstraint = new SecurityConstraint();
                securityConstraint.setUserConstraint("CONFIDENTIAL");
                SecurityCollection collection = new SecurityCollection();
                collection.addPattern("/*");
                securityConstraint.addCollection(collection);
                context.addConstraint(securityConstraint);
            }

            @Override
            protected TomcatWebServer getTomcatWebServer(Tomcat tomcat) {
                new File(tomcat.getServer().getCatalinaBase(), "webapp").mkdirs();
                try {
                    tomcat.addWebapp("/okm", new ClassPathResource("webapp/openkm.war").getFile().toString());
                } catch (Exception ex) {
                    throw new IllegalStateException("Failed to add okm", ex);
                }
                return super.getTomcatWebServer(tomcat);
            }
        }; …
Run Code Online (Sandbox Code Playgroud)

java spring embedded-tomcat-7 spring-boot openkm

7
推荐指数
1
解决办法
288
查看次数

此Web容器尚未启动@Glassfish 4.0.01 web

所以,这是我在REST调用我的服务后得到的:

[2014-04-25T01:06:52.393+0200] [glassfish 4.0] [WARNING] [] [javax.enterprise.web] [tid: _ThreadID=21 _ThreadName=http-listener-1(1)] [timeMillis: 1398380812393] [levelValue: 900] [[
  StandardWrapperValve[ServletAdaptor]: Servlet.service() for servlet ServletAdaptor threw exception
java.lang.IllegalStateException: This web container has not yet been started
    at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1652)
    at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1611)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:270)
    at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)
    at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
    at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
    at sun.reflect.annotation.AnnotationParser.parseSig(AnnotationParser.java:390)
    at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:200)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:88)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:70)
    at java.lang.reflect.Field.declaredAnnotations(Field.java:1128)
    at java.lang.reflect.Field.getAnnotation(Field.java:1114)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldName(ReflectiveTypeAdapterFactory.java:60)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:118)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:72)
    at com.google.gson.Gson.getAdapter(Gson.java:356)
    at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:55)
    at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:96)
    at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:60)
    at com.google.gson.Gson.toJson(Gson.java:593)
    at com.google.gson.Gson.toJson(Gson.java:572)
    at com.google.gson.Gson.toJson(Gson.java:527)
    at com.google.gson.Gson.toJson(Gson.java:507) …
Run Code Online (Sandbox Code Playgroud)

rest glassfish

6
推荐指数
1
解决办法
2万
查看次数

Maven循环依赖

我是Maven的新手,我试图用一些框架创建自己的Java EE Maven项目......我已经开始使用两个模块和一个父模块.问题是我在发出mvn clean时遇到此错误:

[ERROR] The projects in the reactor contain a cyclic reference: Edge between 'Vertex{label='org.tepo:Jporto-web:0.0.1-SNAPSHOT'}' and 'Vertex{label='org.tepo:Jporto-ejb:0.0.1-SNAPSHOT'}' introduces to cycle in the graph org.tepo:Jporto-ejb:0.0.1-SNAPSHOT --> org.tepo:Jporto-web:0.0.1-SNAPSHOT --> org.tepo:Jporto-ejb:0.0.1-SNAPSHOT -> [Help 1]
Run Code Online (Sandbox Code Playgroud)

我知道循环依赖是什么,但我不能在我的poms中看到这样的东西.他们是:父母POM:

<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>org.tepo</groupId>
  <artifactId>Jporto</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>
  <name>jsf library tutto</name>
  <description>fiesta prego grande</description>
  <dependencies>

        <dependency>
        <groupId>org.tepo</groupId>
        <artifactId>Jporto-ejb</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <type>ejb</type>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.tepo</groupId>
        <artifactId>Jporto-web</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <type>war</type>
        <scope>compile</scope>
    </dependency>
 </dependencies>

  <modules>
    <module>Jporto-ejb</module>
    <module>Jporto-web</module>
  </modules>

  <build>  
  <plugins>  
    <plugin>  
      <artifactId>maven-compiler-plugin</artifactId>  
      <inherited>true</inherited>  
      <configuration>  
        <source>1.6</source>  
        <target>1.6</target>  
        <encoding>UTF-8</encoding>  
        <version>2.5.1</version> …
Run Code Online (Sandbox Code Playgroud)

java dependencies maven

3
推荐指数
1
解决办法
1万
查看次数

Angular http拦截器响应头

我制作了一个http拦截器,我需要在其中评估responese头并找到特定的(授权).拦截器本身正在工作但它无法列出我在服务器端设置的标头,我可以清楚地看到设置在firebug的网络选项卡中.

拦截器:

app.factory('HttpItc', function($q, $localStorage, $injector) {
return {
response: function (response) {
   //console.log(response); // Contains the data from the response.

  var freshJwt = response.headers['Authorization'];

  if (freshJwt) {
    $localStorage.jwt = freshJwt;
  }

  // Return the response or promise.
  return response;
}  };});
Run Code Online (Sandbox Code Playgroud)

萤火虫中的标题:

评估回复:

这是我在服务器端Express中设置标头的方法:

return res
                    .header('Authorization', jwt)
                    .header('testHeader', 'testValue')
                    .json(user);
Run Code Online (Sandbox Code Playgroud)

怎么了?如何在http的拦截器中访问响应头?

header http interceptor express angularjs

1
推荐指数
1
解决办法
5866
查看次数