弹簧靴。无法找到“org.hibernate.SessionFactory”类型的 bean

2024-01-07

我似乎无法弄清楚为什么我的 Spring Boot 应用程序无法自动创建 SessionFactory。据我了解,它应该自动获取属性文件并能够创建会话工厂 bean。

我需要将一些 Dao 类中的会话工厂与 hibernate 一起使用,但是下面的简单示例重现了我遇到的问题:

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>

<groupId>mytools</groupId>
<artifactId>spring-boot-hello-world</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <start-class>mytools.spring.hello.Application</start-class>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>2.0.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
        <version>2.0.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.hsqldb</groupId>
        <artifactId>hsqldb</artifactId>
        <version>2.3.4</version>
    </dependency>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.3.0</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.0.1.RELEASE</version>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

应用程序属性:

spring.datasource.url=jdbc:hsqldb:file:databaseFiles/hibData/;hsqldb.write_delay_millis=0
spring.datasource.root=sa
spring.datasource.password=1

spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringSessionContext
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.HSQLDialect
spring.jpa.properties.hibernate.show_sql=false
spring.jpa.properties.hibernate.hbm2ddl.auto=update
spring.jpa.properties.hibernate.jdbc.batch_size=50
spring.jpa.properties.hibernate.order_inserts=true
spring.jpa.properties.hibernate.order_updates=true
spring.jpa.properties.hibernate.jdbc.batch_versioned_data=true

应用类:

package mytools.spring.hello;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {

    @Autowired
    SessionFactory sessionFactory;

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

Output:

    "C:\Program Files\Java\jdk-9.0.4\bin\java" -Dvisualvm.id=13106393222439 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.1.4\lib\idea_rt.jar=51221:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.1.4\bin" -Dfile.encoding=UTF-8 -classpath D:\Projects\Java\springboothelloworld\target\classes;C:\Users\owner\.m2\repository\org\springframework\boot\spring-boot-starter-web\2.0.1.RELEASE\spring-boot-starter-web-2.0.1.RELEASE.jar;C:\Users\owner\.m2\repository\org\springframework\boot\spring-boot-starter\2.0.1.RELEASE\spring-boot-starter-2.0.1.RELEASE.jar;C:\Users\owner\.m2\repository\org\springframework\boot\spring-boot\2.0.1.RELEASE\spring-boot-2.0.1.RELEASE.jar;C:\Users\owner\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.0.1.RELEASE\spring-boot-autoconfigure-2.0.1.RELEASE.jar;C:\Users\owner\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.0.1.RELEASE\spring-boot-starter-logging-2.0.1.RELEASE.jar;C:\Users\owner\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\Users\owner\.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\Users\owner\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.10.0\log4j-to-slf4j-2.10.0.jar;C:\Users\owner\.m2\repository\org\apache\logging\log4j\log4j-api\2.10.0\log4j-api-2.10.0.jar;C:\Users\owner\.m2\repository\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;C:\Users\owner\.m2\repository\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;C:\Users\owner\.m2\repository\org\springframework\spring-core\5.0.5.RELEASE\spring-core-5.0.5.RELEASE.jar;C:\Users\owner\.m2\repository\org\springframework\spring-jcl\5.0.5.RELEASE\spring-jcl-5.0.5.RELEASE.jar;C:\Users\owner\.m2\repository\org\yaml\snakeyaml\1.19\snakeyaml-1.19.jar;C:\Users\owner\.m2\repository\org\springframework\boot\spring-boot-starter-json\2.0.1.RELEASE\spring-boot-starter-json-2.0.1.RELEASE.jar;C:\Users\owner\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.9.5\jackson-databind-2.9.5.jar;C:\Users\owner\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.9.0\jackson-annotations-2.9.0.jar;C:\Users\owner\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.9.5\jackson-core-2.9.5.jar;C:\Users\owner\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.9.5\jackson-datatype-jdk8-2.9.5.jar;C:\Users\owner\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.9.5\jackson-datatype-jsr310-2.9.5.jar;C:\Users\owner\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.9.5\jackson-module-parameter-names-2.9.5.jar;C:\Users\owner\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\2.0.1.RELEASE\spring-boot-starter-tomcat-2.0.1.RELEASE.jar;C:\Users\owner\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\8.5.29\tomcat-embed-core-8.5.29.jar;C:\Users\owner\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\8.5.29\tomcat-embed-el-8.5.29.jar;C:\Users\owner\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\8.5.29\tomcat-embed-websocket-8.5.29.jar;C:\Users\owner\.m2\repository\org\hibernate\validator\hibernate-validator\6.0.9.Final\hibernate-validator-6.0.9.Final.jar;C:\Users\owner\.m2\repository\javax\validation\validation-api\2.0.1.Final\validation-api-2.0.1.Final.jar;C:\Users\owner\.m2\repository\org\jboss\logging\jboss-logging\3.3.2.Final\jboss-logging-3.3.2.Final.jar;C:\Users\owner\.m2\repository\com\fasterxml\classmate\1.3.4\classmate-1.3.4.jar;C:\Users\owner\.m2\repository\org\springframework\spring-web\5.0.5.RELEASE\spring-web-5.0.5.RELEASE.jar;C:\Users\owner\.m2\repository\org\springframework\spring-beans\5.0.5.RELEASE\spring-beans-5.0.5.RELEASE.jar;C:\Users\owner\.m2\repository\org\springframework\spring-webmvc\5.0.5.RELEASE\spring-webmvc-5.0.5.RELEASE.jar;C:\Users\owner\.m2\repository\org\springframework\spring-aop\5.0.5.RELEASE\spring-aop-5.0.5.RELEASE.jar;C:\Users\owner\.m2\repository\org\springframework\spring-context\5.0.5.RELEASE\spring-context-5.0.5.RELEASE.jar;C:\Users\owner\.m2\repository\org\springframework\spring-expression\5.0.5.RELEASE\spring-expression-5.0.5.RELEASE.jar;C:\Users\owner\.m2\repository\org\springframework\boot\spring-boot-starter-data-jpa\2.0.1.RELEASE\spring-boot-starter-data-jpa-2.0.1.RELEASE.jar;C:\Users\owner\.m2\repository\org\springframework\boot\spring-boot-starter-aop\2.0.1.RELEASE\spring-boot-starter-aop-2.0.1.RELEASE.jar;C:\Users\owner\.m2\repository\org\aspectj\aspectjweaver\1.8.13\aspectjweaver-1.8.13.jar;C:\Users\owner\.m2\repository\org\springframework\boot\spring-boot-starter-jdbc\2.0.1.RELEASE\spring-boot-starter-jdbc-2.0.1.RELEASE.jar;C:\Users\owner\.m2\repository\com\zaxxer\HikariCP\2.7.8\HikariCP-2.7.8.jar;C:\Users\owner\.m2\repository\org\springframework\spring-jdbc\5.0.5.RELEASE\spring-jdbc-5.0.5.RELEASE.jar;C:\Users\owner\.m2\repository\org\hibernate\hibernate-core\5.2.16.Final\hibernate-core-5.2.16.Final.jar;C:\Users\owner\.m2\repository\org\hibernate\javax\persistence\hibernate-jpa-2.1-api\1.0.0.Final\hibernate-jpa-2.1-api-1.0.0.Final.jar;C:\Users\owner\.m2\repository\org\javassist\javassist\3.22.0-GA\javassist-3.22.0-GA.jar;C:\Users\owner\.m2\repository\antlr\antlr\2.7.7\antlr-2.7.7.jar;C:\Users\owner\.m2\repository\org\jboss\jandex\2.0.3.Final\jandex-2.0.3.Final.jar;C:\Users\owner\.m2\repository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar;C:\Users\owner\.m2\repository\org\hibernate\common\hibernate-commons-annotations\5.0.1.Final\hibernate-commons-annotations-5.0.1.Final.jar;C:\Users\owner\.m2\repository\javax\transaction\javax.transaction-api\1.2\javax.transaction-api-1.2.jar;C:\Users\owner\.m2\repository\org\springframework\data\spring-data-jpa\2.0.6.RELEASE\spring-data-jpa-2.0.6.RELEASE.jar;C:\Users\owner\.m2\repository\org\springframework\data\spring-data-commons\2.0.6.RELEASE\spring-data-commons-2.0.6.RELEASE.jar;C:\Users\owner\.m2\repository\org\springframework\spring-orm\5.0.5.RELEASE\spring-orm-5.0.5.RELEASE.jar;C:\Users\owner\.m2\repository\org\springframework\spring-tx\5.0.5.RELEASE\spring-tx-5.0.5.RELEASE.jar;C:\Users\owner\.m2\repository\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar;C:\Users\owner\.m2\repository\org\springframework\spring-aspects\5.0.5.RELEASE\spring-aspects-5.0.5.RELEASE.jar;C:\Users\owner\.m2\repository\org\hsqldb\hsqldb\2.3.4\hsqldb-2.3.4.jar;C:\Users\owner\.m2\repository\javax\xml\bind\jaxb-api\2.3.0\jaxb-api-2.3.0.jar mytools.spring.hello.Application

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.1.RELEASE)

2018-05-12 00:46:57.170  INFO 7944 --- [           main] mytools.spring.hello.Application         : Starting Application on Hulk with PID 7944 (D:\Projects\Java\springboothelloworld\target\classes started by owner in D:\Projects\Java\springboothelloworld)
2018-05-12 00:46:57.170  INFO 7944 --- [           main] mytools.spring.hello.Application         : No active profile set, falling back to default profiles: default
2018-05-12 00:46:57.220  INFO 7944 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@5340477f: startup date [Sat May 12 00:46:57 EEST 2018]; root of context hierarchy
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/C:/Users/owner/.m2/repository/org/springframework/spring-core/5.0.5.RELEASE/spring-core-5.0.5.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2018-05-12 00:46:58.078  INFO 7944 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$6f5d8399] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-05-12 00:46:58.370  INFO 7944 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2018-05-12 00:46:58.390  INFO 7944 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-05-12 00:46:58.390  INFO 7944 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.29
2018-05-12 00:46:58.395  INFO 7944 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk-9.0.4\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\libnvvp;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\libnvvp;C:\Intel\OpenCL\sdk\bin\x64;C:\Intel\OpenCL\sdk\bin\x86;C:\Intel\OpenCL\sdk\bin\Pin;C:\Intel\OpenCL\sdk\bin\GTPin;C:\Program Files\Haskell Platform\8.2.1\lib\extralibs\bin;C:\Program Files\Haskell Platform\8.2.1\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\libnvvp;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Microsoft MPI\Bin\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Git\cmd;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\dotnet\;C:\Program Files\Anaconda3;C:\Program Files\Anaconda3\Scripts;C:\Program Files\Anaconda3\Library\bin;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Haskell Platform\8.2.1\mingw\bin;D:\RunnableBins\myrepos;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\HaskellStack\bin;C:\Users\owner\AppData\Roaming\cabal\bin;C:\Users\owner\AppData\Local\Microsoft\WindowsApps;;.]
2018-05-12 00:46:58.480  INFO 7944 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-05-12 00:46:58.480  INFO 7944 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1260 ms
2018-05-12 00:46:58.570  INFO 7944 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-05-12 00:46:58.575  INFO 7944 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-05-12 00:46:58.575  INFO 7944 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-05-12 00:46:58.575  INFO 7944 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-05-12 00:46:58.575  INFO 7944 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-05-12 00:46:58.695  INFO 7944 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2018-05-12 00:46:58.875  INFO 7944 --- [           main] hsqldb.db..ENGINE                        : open start - state modified
2018-05-12 00:46:58.885  INFO 7944 --- [           main] hsqldb.db..ENGINE                        : checkpointClose start
2018-05-12 00:46:58.885  INFO 7944 --- [           main] hsqldb.db..ENGINE                        : checkpointClose synched
2018-05-12 00:46:58.895  INFO 7944 --- [           main] hsqldb.db..ENGINE                        : checkpointClose script done
2018-05-12 00:46:58.915  INFO 7944 --- [           main] hsqldb.db..ENGINE                        : checkpointClose end
2018-05-12 00:46:58.915  INFO 7944 --- [           main] com.zaxxer.hikari.pool.PoolBase          : HikariPool-1 - Driver does not support get/set network timeout for connections. (feature not supported)
2018-05-12 00:46:58.915  INFO 7944 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2018-05-12 00:46:58.945  INFO 7944 --- [           main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-05-12 00:46:58.960  INFO 7944 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
2018-05-12 00:46:59.010  INFO 7944 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.2.16.Final}
2018-05-12 00:46:59.010  INFO 7944 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2018-05-12 00:46:59.040  INFO 7944 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2018-05-12 00:46:59.120  INFO 7944 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.HSQLDialect
2018-05-12 00:46:59.320  INFO 7944 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-05-12 00:46:59.335  WARN 7944 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'application': Unsatisfied dependency expressed through field 'sessionFactory'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.hibernate.SessionFactory' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
2018-05-12 00:46:59.335  INFO 7944 --- [           main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2018-05-12 00:46:59.335  INFO 7944 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2018-05-12 00:46:59.380  INFO 7944 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
2018-05-12 00:46:59.385  INFO 7944 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2018-05-12 00:46:59.390  INFO 7944 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-05-12 00:46:59.450 ERROR 7944 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field sessionFactory in mytools.spring.hello.Application required a bean of type 'org.hibernate.SessionFactory' that could not be found.


Action:

Consider defining a bean of type 'org.hibernate.SessionFactory' in your configuration.


Process finished with exit code 1

我的问题是,我期望 Spring Boot JPA 自动配置能够自动为我的 Hibernate DAO 配置和连接 SessionFactory。

SessionFactory 是 Hibernate 特有的,而 Spring Boot 自动装配 EntityManager 对象,这对 JPA 来说更通用。

在我的 Dao 对象中将 SessionFactory 交换为 EntityManager 使我能够使用 Spring 的自动配置来连接所有内容。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

弹簧靴。无法找到“org.hibernate.SessionFactory”类型的 bean 的相关文章

  • 如何获取之前的URL?

    我需要调用我的网络应用程序的 URL 例如 如果有一个从 stackoverflow com 到我的网站 foo com 的链接 我需要 Web 应用程序 托管 bean 中的 stackoverflow 链接 感谢所有帮助 谢谢 并不总是
  • jQuery AJAX 调用 Java 方法

    使用 jQuery AJAX 我们可以调用特定的 JAVA 方法 例如从 Action 类 该 Java 方法返回的数据将用于填充一些 HTML 代码 请告诉我是否可以使用 jQuery 轻松完成此操作 就像在 DWR 中一样 此外 对于
  • JPA2 中是否有 OnDelete 的等效注释

    import org hibernate annotations OnDelete OnDelete action org hibernate annotations OnDeleteAction CASCADE List
  • 谷歌应用程序引擎会话

    什么是java应用程序引擎 默认会话超时 如果我们将会话超时设置为非常非常长的时间 会不会产生不良影响 因为谷歌应用程序引擎会话默认情况下仅存储在数据存储中 就像facebook一样 每次访问该页面时 会话仍然永远存在 默认会话超时设置为
  • 没有 Spring 的自定义 Prometheus 指标

    我需要为 Web 应用程序提供自定义指标 问题是我不能使用 Spring 但我必须使用 jax rs 端点 要求非常简单 想象一下 您有一个包含键值对的映射 其中键是指标名称 值是一个简单的整数 它是一个计数器 代码会是这样的 public
  • 将 c3p0 与 Tomcat 8 数据源结合使用

    我有一个加载了数据源的 tomcat 8 服务器 我想知道是否可以将这个DataSource与c3p0连接池管理结合使用 到目前为止 这是我尝试过的 上下文 xml
  • 检测并缩短字符串中的所有网址

    假设我有一条字符串消息 您应该将 file zip 上传到http google com extremelylonglink zip http google com extremelylonglink zip not https stack
  • java.lang.IllegalStateException:提交响应后无法调用 sendRedirect()

    这两天我一直在尝试找出问题所在 我在这里读到我应该在代码中添加一个返回 我做到了 但我仍然得到 java lang IllegalStateException Cannot call sendRedirect after the respo
  • 将 MOXy 设置为 JAXB 提供程序,而在同一包中没有属性文件

    我正在尝试使用 MOXy 作为我的 JAXB 提供程序 以便将内容编组 解组到 XML JSON 中 我创建了 jaxb properties 文件 内容如下 javax xml bind context factory org eclip
  • Eclipse Maven Spring 项目 - 错误

    I need help with an error which make me crazy I started to study Java EE and I am going through tutorial on youtube Ever
  • 帮助将图像从 Servlet 获取到 JSP 页面 [重复]

    这个问题在这里已经有答案了 我目前必须生成一个显示字符串文本的图像 我需要在 Servlet 上制作此图像 然后以某种方式将图像传递到 JSP 页面 以便它可以显示它 我试图避免保存图像 而是以某种方式将图像流式传输到 JSP 自从我开始寻
  • 内部类的构造函数引用在运行时失败并出现VerifyError

    我正在使用 lambda 为内部类构造函数创建供应商ctx gt new SpectatorSwitcher ctx IntelliJ建议我将其更改为SpectatorSwitcher new反而 SpectatorSwitcher 是我正
  • 如何在用户输入数据后重新运行java代码

    嘿 我有一个基本的java 应用程序 显示人们是成年人还是青少年等 我从java开始 在用户输入年龄和字符串后我找不到如何制作它它们被归类为 我希望它重新运行整个过程 以便其他人可以尝试 的节目 我一直在考虑做一个循环 但这对我来说没有用
  • tomcat 中受密码保护的应用程序

    我正在使用 JSP Servlet 开发一个Web应用程序 并且我使用了Tomcat 7 0 33 as a web container 所以我的要求是tomcat中的每个应用程序都会password像受保护的manager applica
  • Eclipse 选项卡宽度不变

    我浏览了一些与此相关的帖子 但它们似乎并不能帮助我解决我的问题 我有一个项目 其中 java 文件以 2 个空格的宽度缩进 我想将所有内容更改为 4 空格宽度 我尝试了 正确的缩进 选项 但当我将几行修改为 4 空格缩进时 它只是将所有内容
  • 非 Spring 托管类中 DI 的编译时编织

    我想为标记为的类配置编译时编织 Configurable注释能够将 spring 依赖项注入到初始化的类中new操作员 我不想使用加载时编织 因为我无权访问应用程序服务器的运行脚本 因此无法修改它 另外 我希望能够在测试中使用此类 我的意思
  • 我如何在java中读取二进制数据文件

    因此 我正在为学校做一个项目 我需要读取二进制数据文件并使用它来生成角色的统计数据 例如力量和智慧 它的设置是让前 8 位组成一个统计数据 我想知道执行此操作的实际语法是什么 是不是就像读文本文件一样 这样 File file new Fi
  • 干净构建 Java 命令行

    我正在使用命令行编译使用 eclipse 编写的项目 如下所示 javac file java 然后运行 java file args here 我将如何运行干净的构建或编译 每当我重新编译时 除非删除所有内容 否则更改不会受到影响 cla
  • 使用反射覆盖最终静态字段是否有限制?

    在我的一些单元测试中 我在最终静态字段上的反射中遇到了奇怪的行为 下面是说明我的问题的示例 我有一个基本的 Singleton 类 其中包含一个 Integer public class BasicHolder private static
  • Java中super关键字的范围和使用

    为什么无法使用 super 关键字访问父类变量 使用以下代码 输出为 feline cougar c c class Feline public String type f public Feline System out print fe

随机推荐

  • Fortran 语言中的 OpenMP

    我很少使用 Fortran 但是我的任务是将遗留代码重写为并行运行 我使用 gfortran 作为我的编译器选择 我在以下位置找到了一些优秀的资源https computing llnl gov tutorials openMP https
  • Sencha Touch 2.1 本机(android)应用程序无法从远程获取 json(它适用于 PC)

    我通过观看此视频创建了我的第一个 Sencha touch 2 应用程序 http youtu be 5F7Gx0 W M4 http youtu be 5F7Gx0 W M4 并且它的商店页面结构如下 Ext define FirstAp
  • 获取原始图像 url Magento (1.6.1.0)

    我有以下代码 cProduct Mage getModel catalog product foreach products id as product id product cProduct gt load product id prod
  • 如何在 Visual Studio 2010 中从自定义属性表设置 PlatformToolset

    我现在正从 VS 2005 迁移到 VS 2010 其产品由少数解决方案组成 每个解决方案包含大量项目 我想利用属性表系统 以便我们的众多配置更容易维护 问题之一是我们想要使用 Windows SDK 7 1 因为我们需要 BaseClas
  • d3.interpolateGnBu 发生了什么

    所以我尝试使用 GnBu 配色方案制作连续的色标 d3 scaleSequential d3 interpolateGnBu domain 0 1 这适用于 d3 scaleSequential d3 interpolateViridis
  • AEM 6.0 Sightly 子节点

    我有一个关于使用 Sightly 访问组件子节点的问题 我有一个模板 它使用 data sly resource 引入基本图像组件 如下所示 div class div 我想做的是根据该图像组件是否实际具有图像集来更改 css 类 为此 我
  • Maven - 如何包含空目录

    默认情况下 在构建过程中 maven 会删除空目录 你知道是否可以在pom中指定一个参数来指示maven在生成的target test classes文件夹中包含空目录 根据这张票 MRESOURCES 36 http jira codeh
  • “DbContextOptionsBuilder”不包含“UseSqlServer”的定义

    我正在尝试使用 C 在 VS 2015 Pro 更新 3 中创建一个 Web API 并针对 NET Core 我正在关注本教程 https docs efproject net en latest platforms aspnetcore
  • Wireshark/tshark 中的 2 通道过滤器

    选项 Y 2 and R in tshark迷惑我很久了 看完说明书我才知道 Y用于单通滤波器和 2在 2 遍过滤器中 如果我们在第 1 遍过滤器结束之前无法获取一些信息 但我还是不明白有什么区别 2 Y blabla and 2 R ba
  • 合并后发出拉取请求的用户不会出现在贡献者列表中

    我有一个回购协议Test GitHub 通知我该用户woo27 谁分叉了我的仓库Test 已经做了一个pull request 这些是官方推荐的合并命令 见下面的截图 git checkout b woo27 master master g
  • 如果 contentedittable = false,如何更改内容样式?

    嘿 我创建了一个可以打开新对话框 一个额外的 HTML 页面 的插件 通过此对话框 用户有机会创建自己的格式模式 我想要什么 我需要一个带有只读文本区域的tinymce编辑器 没问题 但用户必须能够选择粗体 斜体 下划线 字体大小 字体系列
  • JPA 实体和 Hibernate 实体之间的区别

    当我用 Entity 注释一个类并尝试解决依赖关系时 我可以在两个不同的包 javax persistence Entity 和 org hibernate annotations Entity 之间选择包 javax包是JPA的entit
  • 如何从 Vue.js 中深度嵌套的子组件访问数据

    我正在使用 Vue js 构建一个界面 我有一个表格 该表格包含一个地址和其他杂项数据 所以我在Vue中创建了两个组件 UserData and UserAddress UserData包含一个实例UserAddress作为子组件 我想根据
  • $(document).ready 的不同形式

    我见过有人写 document ready function 和一些写作 function 有什么区别以及何时使用什么 是 jQuery 对象本身 它在被调用时实现了一大堆不同的接口 string 运行选择器或构造节点 domElement
  • 单个 CSV 文件中的多个分隔符

    我有一个 CSV 它有三个不同的分隔符 即 和 不同列之间 我如何使用Python解析这个CSV 我的数据如下 2017 01 24 05 19 30 0000 TRANSACTIONDelim secondUSER LOGINDelim
  • 将 iAd 框架和 AdSupport 框架添加到构建阶段 - Xcode 6

    在 Xcode 6 中 如何将 iAd 框架和 AdSupport 框架添加到构建阶段 我转到 构建阶段 页面 但我唯一的选择是添加 新复制文件阶段 新运行脚本阶段 和 新标头阶段 我想要输入的框架属于哪些框架 如何输入这些框架 您应该单击
  • 如何在机器上找到 regasm 位置

    我正在创建一个使用 regasm 将 NET 程序集注册到 COM 的安装程序 不同的客户端将在其计算机上安装不同的 Microsoft Net 版本 我需要提前知道高潮位置才能使用它 我应该只在以下位置寻找它还是还有其他可能的位置 C W
  • Python Regex - 检查大写字母和小写字母

    我正在尝试检查紧随其后的小写字母的大写字母 诀窍在于 在它之前会出现一堆垃圾大写字母和数字 例如 AASKH317298DIUANFProgramming is fun 正如你所看到的 有很多我们不需要的东西直接出现在我们需要的短语之前 P
  • 如何完全迭代 QStandardItemModel?

    我有一个 QStandardItemModel 我将其显示在 QTreeView 中 工作正常 为了突出显示相关行 我想突出显示其中的一些行 因此我有一个 QStringList 其中包含要突出显示的 QStandItem 的名称 QStr
  • 弹簧靴。无法找到“org.hibernate.SessionFactory”类型的 bean

    我似乎无法弄清楚为什么我的 Spring Boot 应用程序无法自动创建 SessionFactory 据我了解 它应该自动获取属性文件并能够创建会话工厂 bean 我需要将一些 Dao 类中的会话工厂与 hibernate 一起使用 但是