cx_Oracle pip install failed: oci.h: No such file or directory

cx_Oracle pip install fails: oci.h: No such file or directory

我对这个有点迷茫。我还尝试安装旧版本的 cx_Oracle,我已将其安装在单独的 virtualenv 中,但它也在同一个地方失败并显示相同的错误消息。

$ pip install cx_Oracle

(...)



cx_Oracle.c:10:17: error: oci.h: No such file or directory

cx_Oracle.c:11:18: error: orid.h: No such file or directory

cx_Oracle.c:12:16: error: xa.h: No such file or directory



error: command 'gcc' failed with exit status 1

(...)

----------------------------------------

Cleaning up...

Command /R/.virtualenv/myenv/bin/python -c"import setuptools, tokenize;__file__='/R/.virtualenv/myenv/build/cx-Oracle/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\

\

', '\

'), __file__, 'exec'))" install --record /tmp/pip-g5eyNG-record/install-record.txt --single-version-externally-managed --compile --install-headers /R/.virtualenv/myenv/include/site/python2.7 failed with error code 1 in /R/.virtualenv/myenv/build/cx-Oracle

Traceback (most recent call last):

 File"/R/.virtualenv/myenv/bin/pip", line 11, in <module>

  sys.exit(main())

 File"/R/.virtualenv/myenv/lib/python2.7/site-packages/pip/__init__.py", line 185, in main

  return command.main(cmd_args)

 File"/R/.virtualenv/myenv/lib/python2.7/site-packages/pip/basecommand.py", line 161, in main

  text = '\

'.join(complete_log)

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 70: ordinal not in range(128)
export ORACLE_HOME=/opt/oracle/instantclient_12_2

export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2

cd $ORACLE_HOME

unzip /sdk/ottclasses.zip

cp -R ./sdk/* .

cp -R ./sdk/include/* .

ln -s libclntsh.so.12.1 libclntsh.so

ln -s libocci.so.12.1 libocci.so
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/home/oracle/product/12.1.0/rdbms/demo -I/home/oracle/product/12.1.0/rdbms/public -I/usr/include/python2.7 -c cx_Oracle.c -o build/temp.linux-x86_64-2.7-12c/cx_Oracle.o -DBUILD_VERSION=5.2.1

cx_Oracle.c:10:17: error: oci.h: No such file or directory

cx_Oracle.c:11:18: error: orid.h: No such file or directory

cx_Oracle.c:27:2: error: #error Unsupported version of OCI.
-I dir Add the directory dir to the list of directories to be searched for header files. ....-I/home/oracle/product/12.1.0/rdbms/demo 

-I/home/oracle/product/12.1.0/rdbms/public 

-I/usr/include/python2.7pip install cx_Oracle --global-option=build_ext --global-option="-I/home/oracle/instantclient_12_1/sdk/include"

完整的错误日志


我在尝试 pip install cx_oracle 时遇到了类似的错误,即使在安装 Oracle 即时客户端之后,并且在设置 $ORACLE_HOME 和 $LD_LIBRARY_PATH 以包含客户端的路径之后。

听起来您可能已经安装了 Instant Client,但没有安装 Instant Client SDK。 SDK 是一个单独的下载/安装,cx_oracle 似乎需要两者,因为缺少的包含(\\'oci.h\\' 和所有其余部分)位于 SDK 中。

如果您还没有去过那里,可以在这里找到 Oracle Instant Client / SDK 下载页面:

http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html

假设您已经下载并安装了适合您平台的客户端,例如这个:

oracle-instantclient11.2-basic-11.2.0.1.0-1.x86_64.zip

您还需要下载并安装相应的 SDK,例如这个:

oracle-instantclient11.2-sdk-11.2.0.1.0-1.x86_64.zip

只要 SDK 安装在 ORACLE_HOME 和 LD_LIBRARY_PATH 路径中的某处,包含应该会解析。


问题在于 bschulz 指出的 SDK 不存在。我能够通过以下步骤解决此问题:

  • 下载并安装/解压 $ORACLE_HOME 中的 "instantclient-basic" 和 "instantclient-sdk"。

    你可以从这里获得它们

  • 设置/etc/environment

    $ pip install cx_Oracle
    
    (...)
    
    
    
    cx_Oracle.c:10:17: error: oci.h: No such file or directory
    
    cx_Oracle.c:11:18: error: orid.h: No such file or directory
    
    cx_Oracle.c:12:16: error: xa.h: No such file or directory
    
    
    
    error: command 'gcc' failed with exit status 1
    
    (...)
    
    ----------------------------------------
    
    Cleaning up...
    
    Command /R/.virtualenv/myenv/bin/python -c"import setuptools, tokenize;__file__='/R/.virtualenv/myenv/build/cx-Oracle/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\
    
    \
    
    ', '\
    
    '), __file__, 'exec'))" install --record /tmp/pip-g5eyNG-record/install-record.txt --single-version-externally-managed --compile --install-headers /R/.virtualenv/myenv/include/site/python2.7 failed with error code 1 in /R/.virtualenv/myenv/build/cx-Oracle
    
    Traceback (most recent call last):
    
     File"/R/.virtualenv/myenv/bin/pip", line 11, in <module>
    
      sys.exit(main())
    
     File"/R/.virtualenv/myenv/lib/python2.7/site-packages/pip/__init__.py", line 185, in main
    
      return command.main(cmd_args)
    
     File"/R/.virtualenv/myenv/lib/python2.7/site-packages/pip/basecommand.py", line 161, in main
    
      text = '\
    
    '.join(complete_log)
    
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 70: ordinal not in range(128)
    export ORACLE_HOME=/opt/oracle/instantclient_12_2
    
    export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2
    
    cd $ORACLE_HOME
    
    unzip /sdk/ottclasses.zip
    
    cp -R ./sdk/* .
    
    cp -R ./sdk/include/* .
    
    ln -s libclntsh.so.12.1 libclntsh.so
    
    ln -s libocci.so.12.1 libocci.so
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/home/oracle/product/12.1.0/rdbms/demo -I/home/oracle/product/12.1.0/rdbms/public -I/usr/include/python2.7 -c cx_Oracle.c -o build/temp.linux-x86_64-2.7-12c/cx_Oracle.o -DBUILD_VERSION=5.2.1
    
    cx_Oracle.c:10:17: error: oci.h: No such file or directory
    
    cx_Oracle.c:11:18: error: orid.h: No such file or directory
    
    cx_Oracle.c:27:2: error: #error Unsupported version of OCI.
    -I dir Add the directory dir to the list of directories to be searched for header files. ....-I/home/oracle/product/12.1.0/rdbms/demo 
    
    -I/home/oracle/product/12.1.0/rdbms/public 
    
    -I/usr/include/python2.7pip install cx_Oracle --global-option=build_ext --global-option="-I/home/oracle/instantclient_12_1/sdk/include"
  • 现在运行 pip install cx_Oracle==5.3

    我遵循了这些,它为我成功安装了 5.3。

    您可能需要安装一些额外的依赖项,这些依赖项列在您应该下载/安装的软件包的文档中。


    在 Mac OS 上也经历过同样的事情。

    首先,我已遵循此答案并通过 brew 安装了 instantclient-basicinstantclient-sqlplus

    然后按照同样的想法,我也下载了 SDK Package (instantclient-sdk-macos.x64-19.3.0.0.0dbru.zip) 并执行:

    brew install instantclient-sdk


    来自 cx_Oracle 6:

    • PyPI 上有二进制轮子,所以很多人不需要

      编译

    • 如果确实需要编译,Oracle 头文件不是

      需要,并且你不应该/不需要在使用 Oracle 时设置 ORACLE_HOME

      即时客户端。

    在 cx_Oracle 5.2 和 5.3 中,如果您使用 Instant Client RPM,则无需在安装时设置 ORACLE_HOME,也无需在运行时设置 LD_LIBRARY_PATH。如果您使用 Instant Client zip(或真正的 DB $ORACLE_HOME 安装),您可以在安装 cx_Oracle 之前设置 FORCE_RPATH=1。如果你这样做,你将不需要在运行时设置 LD_LIBRARY_PATH。这个特性在 cx_Oracle 中已经有几个版本了。


    正如 bschulz 解释的,这个问题通常通过设置 ORACLE_HOME 和 LD_LIBRARY_PATH 环境变量来确保 gcc 可以访问头文件来解决。

    就我而言,它没有解决问题,但检查错误跟踪给了我解决问题的提示。

    执行 pip install cx_Oracle 显示此错误:

    $ pip install cx_Oracle
    
    (...)
    
    
    
    cx_Oracle.c:10:17: error: oci.h: No such file or directory
    
    cx_Oracle.c:11:18: error: orid.h: No such file or directory
    
    cx_Oracle.c:12:16: error: xa.h: No such file or directory
    
    
    
    error: command 'gcc' failed with exit status 1
    
    (...)
    
    ----------------------------------------
    
    Cleaning up...
    
    Command /R/.virtualenv/myenv/bin/python -c"import setuptools, tokenize;__file__='/R/.virtualenv/myenv/build/cx-Oracle/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\
    
    \
    
    ', '\
    
    '), __file__, 'exec'))" install --record /tmp/pip-g5eyNG-record/install-record.txt --single-version-externally-managed --compile --install-headers /R/.virtualenv/myenv/include/site/python2.7 failed with error code 1 in /R/.virtualenv/myenv/build/cx-Oracle
    
    Traceback (most recent call last):
    
     File"/R/.virtualenv/myenv/bin/pip", line 11, in <module>
    
      sys.exit(main())
    
     File"/R/.virtualenv/myenv/lib/python2.7/site-packages/pip/__init__.py", line 185, in main
    
      return command.main(cmd_args)
    
     File"/R/.virtualenv/myenv/lib/python2.7/site-packages/pip/basecommand.py", line 161, in main
    
      text = '\
    
    '.join(complete_log)
    
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 70: ordinal not in range(128)
    export ORACLE_HOME=/opt/oracle/instantclient_12_2
    
    export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2
    
    cd $ORACLE_HOME
    
    unzip /sdk/ottclasses.zip
    
    cp -R ./sdk/* .
    
    cp -R ./sdk/include/* .
    
    ln -s libclntsh.so.12.1 libclntsh.so
    
    ln -s libocci.so.12.1 libocci.so
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/home/oracle/product/12.1.0/rdbms/demo -I/home/oracle/product/12.1.0/rdbms/public -I/usr/include/python2.7 -c cx_Oracle.c -o build/temp.linux-x86_64-2.7-12c/cx_Oracle.o -DBUILD_VERSION=5.2.1
    
    cx_Oracle.c:10:17: error: oci.h: No such file or directory
    
    cx_Oracle.c:11:18: error: orid.h: No such file or directory
    
    cx_Oracle.c:27:2: error: #error Unsupported version of OCI.
    -I dir Add the directory dir to the list of directories to be searched for header files. ....-I/home/oracle/product/12.1.0/rdbms/demo 
    
    -I/home/oracle/product/12.1.0/rdbms/public 
    
    -I/usr/include/python2.7pip install cx_Oracle --global-option=build_ext --global-option="-I/home/oracle/instantclient_12_1/sdk/include"

    在 man gcc:

    中查找 -I 标志

    $ pip install cx_Oracle
    
    (...)
    
    
    
    cx_Oracle.c:10:17: error: oci.h: No such file or directory
    
    cx_Oracle.c:11:18: error: orid.h: No such file or directory
    
    cx_Oracle.c:12:16: error: xa.h: No such file or directory
    
    
    
    error: command 'gcc' failed with exit status 1
    
    (...)
    
    ----------------------------------------
    
    Cleaning up...
    
    Command /R/.virtualenv/myenv/bin/python -c"import setuptools, tokenize;__file__='/R/.virtualenv/myenv/build/cx-Oracle/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\
    
    \
    
    ', '\
    
    '), __file__, 'exec'))" install --record /tmp/pip-g5eyNG-record/install-record.txt --single-version-externally-managed --compile --install-headers /R/.virtualenv/myenv/include/site/python2.7 failed with error code 1 in /R/.virtualenv/myenv/build/cx-Oracle
    
    Traceback (most recent call last):
    
     File"/R/.virtualenv/myenv/bin/pip", line 11, in <module>
    
      sys.exit(main())
    
     File"/R/.virtualenv/myenv/lib/python2.7/site-packages/pip/__init__.py", line 185, in main
    
      return command.main(cmd_args)
    
     File"/R/.virtualenv/myenv/lib/python2.7/site-packages/pip/basecommand.py", line 161, in main
    
      text = '\
    
    '.join(complete_log)
    
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 70: ordinal not in range(128)
    export ORACLE_HOME=/opt/oracle/instantclient_12_2
    
    export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2
    
    cd $ORACLE_HOME
    
    unzip /sdk/ottclasses.zip
    
    cp -R ./sdk/* .
    
    cp -R ./sdk/include/* .
    
    ln -s libclntsh.so.12.1 libclntsh.so
    
    ln -s libocci.so.12.1 libocci.so
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/home/oracle/product/12.1.0/rdbms/demo -I/home/oracle/product/12.1.0/rdbms/public -I/usr/include/python2.7 -c cx_Oracle.c -o build/temp.linux-x86_64-2.7-12c/cx_Oracle.o -DBUILD_VERSION=5.2.1
    
    cx_Oracle.c:10:17: error: oci.h: No such file or directory
    
    cx_Oracle.c:11:18: error: orid.h: No such file or directory
    
    cx_Oracle.c:27:2: error: #error Unsupported version of OCI.
    -I dir Add the directory dir to the list of directories to be searched for header files. ....-I/home/oracle/product/12.1.0/rdbms/demo 
    
    -I/home/oracle/product/12.1.0/rdbms/public 
    
    -I/usr/include/python2.7pip install cx_Oracle --global-option=build_ext --global-option="-I/home/oracle/instantclient_12_1/sdk/include"

    所以问题出在这些标志值上:

    $ pip install cx_Oracle
    
    (...)
    
    
    
    cx_Oracle.c:10:17: error: oci.h: No such file or directory
    
    cx_Oracle.c:11:18: error: orid.h: No such file or directory
    
    cx_Oracle.c:12:16: error: xa.h: No such file or directory
    
    
    
    error: command 'gcc' failed with exit status 1
    
    (...)
    
    ----------------------------------------
    
    Cleaning up...
    
    Command /R/.virtualenv/myenv/bin/python -c"import setuptools, tokenize;__file__='/R/.virtualenv/myenv/build/cx-Oracle/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\
    
    \
    
    ', '\
    
    '), __file__, 'exec'))" install --record /tmp/pip-g5eyNG-record/install-record.txt --single-version-externally-managed --compile --install-headers /R/.virtualenv/myenv/include/site/python2.7 failed with error code 1 in /R/.virtualenv/myenv/build/cx-Oracle
    
    Traceback (most recent call last):
    
     File"/R/.virtualenv/myenv/bin/pip", line 11, in <module>
    
      sys.exit(main())
    
     File"/R/.virtualenv/myenv/lib/python2.7/site-packages/pip/__init__.py", line 185, in main
    
      return command.main(cmd_args)
    
     File"/R/.virtualenv/myenv/lib/python2.7/site-packages/pip/basecommand.py", line 161, in main
    
      text = '\
    
    '.join(complete_log)
    
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 70: ordinal not in range(128)
    export ORACLE_HOME=/opt/oracle/instantclient_12_2
    
    export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2
    
    cd $ORACLE_HOME
    
    unzip /sdk/ottclasses.zip
    
    cp -R ./sdk/* .
    
    cp -R ./sdk/include/* .
    
    ln -s libclntsh.so.12.1 libclntsh.so
    
    ln -s libocci.so.12.1 libocci.so
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/home/oracle/product/12.1.0/rdbms/demo -I/home/oracle/product/12.1.0/rdbms/public -I/usr/include/python2.7 -c cx_Oracle.c -o build/temp.linux-x86_64-2.7-12c/cx_Oracle.o -DBUILD_VERSION=5.2.1
    
    cx_Oracle.c:10:17: error: oci.h: No such file or directory
    
    cx_Oracle.c:11:18: error: orid.h: No such file or directory
    
    cx_Oracle.c:27:2: error: #error Unsupported version of OCI.
    -I dir Add the directory dir to the list of directories to be searched for header files. ....-I/home/oracle/product/12.1.0/rdbms/demo 
    
    -I/home/oracle/product/12.1.0/rdbms/public 
    
    -I/usr/include/python2.7pip install cx_Oracle --global-option=build_ext --global-option="-I/home/oracle/instantclient_12_1/sdk/include"

    我无法真正说出为什么将 -I 标志设置为这些值,但使其工作的简单方法是修改从 pip 命令行传递正确值的标志:

    $ pip install cx_Oracle
    
    (...)
    
    
    
    cx_Oracle.c:10:17: error: oci.h: No such file or directory
    
    cx_Oracle.c:11:18: error: orid.h: No such file or directory
    
    cx_Oracle.c:12:16: error: xa.h: No such file or directory
    
    
    
    error: command 'gcc' failed with exit status 1
    
    (...)
    
    ----------------------------------------
    
    Cleaning up...
    
    Command /R/.virtualenv/myenv/bin/python -c"import setuptools, tokenize;__file__='/R/.virtualenv/myenv/build/cx-Oracle/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\
    
    \
    
    ', '\
    
    '), __file__, 'exec'))" install --record /tmp/pip-g5eyNG-record/install-record.txt --single-version-externally-managed --compile --install-headers /R/.virtualenv/myenv/include/site/python2.7 failed with error code 1 in /R/.virtualenv/myenv/build/cx-Oracle
    
    Traceback (most recent call last):
    
     File"/R/.virtualenv/myenv/bin/pip", line 11, in <module>
    
      sys.exit(main())
    
     File"/R/.virtualenv/myenv/lib/python2.7/site-packages/pip/__init__.py", line 185, in main
    
      return command.main(cmd_args)
    
     File"/R/.virtualenv/myenv/lib/python2.7/site-packages/pip/basecommand.py", line 161, in main
    
      text = '\
    
    '.join(complete_log)
    
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 70: ordinal not in range(128)
    export ORACLE_HOME=/opt/oracle/instantclient_12_2
    
    export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2
    
    cd $ORACLE_HOME
    
    unzip /sdk/ottclasses.zip
    
    cp -R ./sdk/* .
    
    cp -R ./sdk/include/* .
    
    ln -s libclntsh.so.12.1 libclntsh.so
    
    ln -s libocci.so.12.1 libocci.so
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/home/oracle/product/12.1.0/rdbms/demo -I/home/oracle/product/12.1.0/rdbms/public -I/usr/include/python2.7 -c cx_Oracle.c -o build/temp.linux-x86_64-2.7-12c/cx_Oracle.o -DBUILD_VERSION=5.2.1
    
    cx_Oracle.c:10:17: error: oci.h: No such file or directory
    
    cx_Oracle.c:11:18: error: orid.h: No such file or directory
    
    cx_Oracle.c:27:2: error: #error Unsupported version of OCI.
    -I dir Add the directory dir to the list of directories to be searched for header files. ....-I/home/oracle/product/12.1.0/rdbms/demo 
    
    -I/home/oracle/product/12.1.0/rdbms/public 
    
    -I/usr/include/python2.7pip install cx_Oracle --global-option=build_ext --global-option="-I/home/oracle/instantclient_12_1/sdk/include"

    这样一个新的 -I 值被发送到 gcc 并且安装正确结束。


相关推荐

  • Spring部署设置openshift

    Springdeploymentsettingsopenshift我有一个问题让我抓狂了三天。我根据OpenShift帐户上的教程部署了spring-eap6-quickstart代码。我已配置调试选项,并且已将Eclipse工作区与OpehShift服务器同步-服务器上的一切工作正常,但在Eclipse中出现无法消除的错误。我有这个错误:cvc-complex-type.2.4.a:Invali…
    2025-04-161
  • 检查Java中正则表达式中模式的第n次出现

    CheckfornthoccurrenceofpatterninregularexpressioninJava本问题已经有最佳答案,请猛点这里访问。我想使用Java正则表达式检查输入字符串中特定模式的第n次出现。你能建议怎么做吗?这应该可以工作:MatchResultfindNthOccurance(intn,Patternp,CharSequencesrc){Matcherm=p.matcher…
    2025-04-161
  • 如何让 JTable 停留在已编辑的单元格上

    HowtohaveJTablestayingontheeditedcell如果有人编辑JTable的单元格内容并按Enter,则内容会被修改并且表格选择会移动到下一行。是否可以禁止JTable在单元格编辑后转到下一行?原因是我的程序使用ListSelectionListener在单元格选择上同步了其他一些小部件,并且我不想在编辑当前单元格后选择下一行。Enter的默认绑定是名为selectNext…
    2025-04-161
  • Weblogic 12c 部署

    Weblogic12cdeploy我正在尝试将我的应用程序从Tomcat迁移到Weblogic12.2.1.3.0。我能够毫无错误地部署应用程序,但我遇到了与持久性提供程序相关的运行时错误。这是堆栈跟踪:javax.validation.ValidationException:CalltoTraversableResolver.isReachable()threwanexceptionatorg.…
    2025-04-161
  • Resteasy Content-Type 默认值

    ResteasyContent-Typedefaults我正在使用Resteasy编写一个可以返回JSON和XML的应用程序,但可以选择默认为XML。这是我的方法:@GET@Path("/content")@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})publicStringcontentListRequestXm…
    2025-04-161
  • 代码不会停止运行,在 Java 中

    thecodedoesn'tstoprunning,inJava我正在用Java解决项目Euler中的问题10,即"Thesumoftheprimesbelow10is2+3+5+7=17.Findthesumofalltheprimesbelowtwomillion."我的代码是packageprojecteuler_1;importjava.math.BigInteger;importjava…
    2025-04-161
  • Out of memory java heap space

    Outofmemoryjavaheapspace我正在尝试将大量文件从服务器发送到多个客户端。当我尝试发送大小为700mb的文件时,它显示了"OutOfMemoryjavaheapspace"错误。我正在使用Netbeans7.1.2版本。我还在属性中尝试了VMoption。但仍然发生同样的错误。我认为阅读整个文件存在一些问题。下面的代码最多可用于300mb。请给我一些建议。提前致谢publicc…
    2025-04-161
  • Log4j 记录到共享日志文件

    Log4jLoggingtoaSharedLogFile有没有办法将log4j日志记录事件写入也被其他应用程序写入的日志文件。其他应用程序可以是非Java应用程序。有什么缺点?锁定问题?格式化?Log4j有一个SocketAppender,它将向服务发送事件,您可以自己实现或使用与Log4j捆绑的简单实现。它还支持syslogd和Windows事件日志,这对于尝试将日志输出与来自非Java应用程序…
    2025-04-161