当前位置: 首页 > 知识库问答 >
问题:

在Liferay 6.2插件中获取JNDI数据源

斜单鹗
2023-03-14

我有一个Liferay6.2钩子,我正在尝试在运行Liferay的WebLogic12c容器中配置JNDI数据源。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
                    http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">

<bean id="bootstrapDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="java:comp/env/jdbc/bootstrap"/>
</bean>

</beans>
<?xml version="1.0" encoding="UTF-8"?>
<web-app
version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<resource-ref>
    <description>Datasource</description>
    <res-ref-name>jdbc/bootstrap</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

</web-app>

谢谢保罗

共有1个答案

司马洲
2023-03-14

我从jndiName属性值中删除了“java:comp/env/”前缀。这就解决了问题。这很奇怪,因为容器中的其他应用程序需要“java:comp/env/”前缀。

spring-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
                    http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">

<bean id="bootstrapDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="jdbc/bootstrap"/>
</bean>

</beans>
 类似资料:
  • 我是Laravel的新手,我正在使用Laravel 8进行我的项目。 在edit_customer.blade.php中,我需要显示单个数据。 在控制器文件中,我使用了以下代码: 在视图文件中,我使用{{$CurrentCustomer}}得到以下结果: [{“customer_id”:1,“current_admin_id”:0,“customer_type”:“customer_type_pu

  • 在调用这个组件的地方 接收childer组件作为插槽,在parent中 获取不到默认插槽的属性b,不知道为什么

  • 问题内容: 我正在尝试设置一些jUnit测试。我们的数据库由服务器使用JNDI连接。我们在root.xml中有一个描述设置的xml。如何设置jUnit以连接数据库?我希望它只是从root.xml中读取内容,但是无论如何我都愿意进行设置。 问题答案: 我发现最好的方法是使用称为Simple- Jndi的 东西。 我将此添加到Maven文件中: 您可以在此处下载软件包,下载内容包含说明手册。 http

  • 我想手动获取Yoast SEO生成的数据,请参见下面的示例代码 此数据由Yoast生成,并自动将其添加到头标签中。 我不想使用wp_head();因为它还会生成其他脚本、样式和任何你在wordpress网站上的插件或代码。 我不需要所有这些代码。我只想得到Yoast SEO生成的代码,如上图所示。你知道我该怎么做吗?

  • 我是个新手,所以我不知道该怎么称呼它。因此,如果以前有人问过这个问题,我很抱歉。我可能想做的是映射数据,但我不知道如何做。 以上是我的提取组件。从API获取的数据包括id、lastname、firstname。但是,我想分配id作为鼻涕虫,然后将firstname lastname更改为name 因此,与其在客户机阵列中看到这一点, 我想看到这样的东西:

  • 我有这部分代码: 现在想返回插入或更新的数据作为响应,但是在谷歌上看到很多帖子后,所有尝试都失败了,我怎么能这样做?没有上次插入的id 但返回布尔值: 如何在雄辩的ORM laravel最后插入id 大多数主题想要返回,但我想要所有数据。