首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过maven插件在OpenLiberty中安装默认的OpenLiberty

通过maven插件在OpenLiberty中安装默认的OpenLiberty
EN

Stack Overflow用户
提问于 2020-01-29 01:42:23
回答 2查看 722关注 0票数 1

我试图为openFree20.0.0.1设置一个DefaultDataSource。

src/config/config/server.xml是:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">

    <!-- Enable features -->
    <featureManager>
        <feature>javaee-8.0</feature>
    </featureManager>

    <!-- This template enables security. To get the full use of all the capabilities, a keystore and user registry are required. -->

    <!-- For the keystore, default keys are generated and stored in a keystore. To provide the keystore password, generate an 
         encoded password using bin/securityUtility encode and add it below in the password attribute of the keyStore element. 
         Then uncomment the keyStore element. -->
    <!--
    <keyStore password=""/> 
    -->

    <!--For a user registry configuration, configure your user registry. For example, configure a basic user registry using the
        basicRegistry element. Specify your own user name below in the name attribute of the user element. For the password, 
        generate an encoded password using bin/securityUtility encode and add it in the password attribute of the user element. 
        Then uncomment the user element. -->
    <basicRegistry id="basic" realm="BasicRealm"> 
        <!-- <user name="yourUserName" password="" />  --> 
    </basicRegistry>

    <!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
    <httpEndpoint id="defaultHttpEndpoint"
                  httpPort="9080"
                  httpsPort="9443" />

    <!-- Automatically expand WAR files and EAR files -->
    <applicationManager autoExpand="true"/>

    <!-- Derby Library Configuration -->    
    <library id="derbyJDBCLib">
      <fileset dir="${shared.resource.dir}" includes="derby*.jar"/>
    </library>

    <!-- Datasource Configuration -->
    <!-- remove jndiName="" to serve java:comp/DefaultDataSource for Java EE 7 or above -->
    <dataSource id="DefaultDataSource">
      <jdbcDriver libraryRef="derbyJDBCLib" />
      <properties.derby.embedded databaseName="taskdb" createDatabase="create"/>
    </dataSource>

</server>

liberty-maven-plugin是在pom.xml中配置的。

代码语言:javascript
复制
 <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>3.1.1</version>
                        <executions>
                            <execution>
                                <id>copy</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>   
                            </execution>
                        </executions>                     
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.apache.derby</groupId>
                                    <artifactId>derby</artifactId>
                                    <version>10.14.2.0</version>
                                    <type>jar</type>
                                    <overWrite>false</overWrite>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${project.build.directory}/liberty/wlp/usr/shared/resources</outputDirectory>
                        </configuration>                                    
                    </plugin>             
                    <!-- Enable liberty-maven-plugin -->
                    <plugin>
                        <groupId>io.openliberty.tools</groupId>
                        <artifactId>liberty-maven-plugin</artifactId>
                        <version>3.1</version>
                        <configuration>
                            <libertyRuntimeVersion>20.0.0.1</libertyRuntimeVersion>
                        </configuration>
                    </plugin>

我使用maven-dependency-plugin将德比复制到maven-dependency-plugin

但是当我运行mvn clean liberty:run -Popenliberty时。我发现先复制了德比,然后liberty:run目标会删除目标/自由,如何防止自由maven插件删除这个文件夹?

我使用Maven profile openliberty作为自由服务器,检查完全码

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-01-29 17:06:05

在执行应用程序编译、war打包等的前一次构建调用之后,您似乎正在运行mvn clean liberty:run -Popenliberty命令。通过在您提供的命令中运行clean阶段,Maven将删除target文件夹,从而删除任何以前调用的输出。这与自由Maven插件的行为无关。

自由Maven插件库中有一个支持将依赖项复制到共享资源目录中的公开发行

作为一种解决办法,您可以:

代码语言:javascript
复制
mvn clean install liberty:create dependency:copy liberty:run -Popenliberty

这样,LMP将创建服务器,然后复制Derby依赖项,然后在前台启动服务器。

票数 1
EN

Stack Overflow用户

发布于 2021-07-13 20:46:57

从自由Maven插件的3.3版开始,有一个copyDependencies参数:

pom.xml

代码语言:javascript
复制
<plugins>
  <plugin>
    <groupId>io.openliberty.tools</groupId>
    <artifactId>liberty-maven-plugin</artifactId>
    <version>3.3.4</version> 
    <configuration>
      <!-- Usually best to add configuration at the plugin level rather than trying to configure particular executions -->
      <copyDependencies>
        <dependencyGroup>
          <!-- Relative to server config directory -->
          <location>lib/global/jdbc</location>
          <dependency>
            <groupId>org.apache.derby</groupId>
            <artifactId>derby</artifactId>
          </dependency>
        </dependencyGroup>
      </copyDependencies>
    </configuration>
      ...

server.xml

代码语言:javascript
复制
...
<!-- Derby Library Configuration -->    
<library id="derbyJDBCLib">
  <fileset dir="${server.config.dir}/lib/global/jdbc" includes="derby*.jar"/>
</library>
...

有关更多细节,请参见文档

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59959495

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档