现在可能这种需求比较少,国内文档也不多,最近花了半天的时间配一下
1.首先因为用的是CE 版本和Open liberty,websphere Liberty的开源版本。如果用的是收费版可以直接参考这个Run/Debug Configuration: WebSphere Server | IntelliJ IDEA
2.这里我们用Maven,用其他的可以参考这个,所以请提前安装好maven,在命令行执行
mvn -help好用
Open Liberty development mode - OpenLiberty.io
在porm.xml 里 加入
<plugins>
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>3.5.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
最主要的就是 iberty-maven-plugin
3.在 IntelliJ IDEA CE 里添加 插件
InteliJ--->Preference-->Plungins 搜索Open Liberty tools,安装
4这样你就可以通过UI 来启动server,当然其实也就是相当用帮你输入个命令
Develop Open Liberty apps in IntelliJ with dev mode - OpenLiberty.io
这里有详细的步骤
5 这样你就可以start一个默认的server了
当然你也可以通过ternimal 直接输入mvn 的命令 ,例如 mvn liberty:run
更多命令参考,里面有各种详细用法
a.默认的server.xml路径是
/target/liberty/wlp/usr/servers/defaultServer/server.xml
b.默认plugin 插件会默认我们的war安装的路径是target/liberty/wlp/usr/servers/defaultServer/dropins
这样你就不能在server.xml 中再定义你的war了,因为这样会重复,
比如这个定义在server.xml中就会出错
<webApplication contextRoot="root/rest" id="rest" location="rest.war" name="my-rest">
如果你对这个war 有一些定制化的需求,就需要在source里建server.xml如下图所示,这样就会覆盖默认生产的server.xml,而且会deploy 到apps 而不是dropins
c现在liberty 默认生成的cert 是key.p12 路径是 /target/liberty/wlp/usr/servers/defaultServer/resources/security
当然这个是最新的标准,如果还想用key.jks,需要制定文件
<keyStore id="defaultKeyStore" location="key.jks" password="changeit"/>
这样就不会生产key.p12 而是key.jks