问题
I have: Eclispse Version: 2019-06 (4.12.0) Build id: 20190614-1200
Liferay 7.2.0 CE GA1. I use Gradle.
I created a rest module.
First Deploy my code of the MyRestWebserviceApplication.java was:
package com.liferaystack.application;
/**
* Copyright 2000-present Liferay, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.model.User;
import com.liferay.portal.kernel.service.UserLocalService;
import java.util.Collections;
import java.util.Set;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Application;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants;
/**
* @author Liferay
*/
@Component(
property = {
JaxrsWhiteboardConstants.JAX_RS_APPLICATION_BASE + "=/pippo",
JaxrsWhiteboardConstants.JAX_RS_NAME + "=Pippo"
},
service = Application.class
)
public class MyRestWebserviceApplication extends Application {
public Set<Object> getSingletons() {
return Collections.<Object>singleton(this);
}
@GET
@Produces("text/plain")
public String working() {
return "It works!";
}
@GET
@Path("/morning")
@Produces("text/plain")
public String hello() {
return "Good morning! test1";
}
@GET
@Path("/mattina")
@Produces("text/plain")
public String helloGa() {
return "Good morning test2";
}
@GET
@Path("/buonamattina")
@Produces("text/plain")
public String buonamattina() {
return "BUONA MATTINA!";
}
@GET
@Path("/morning/{name}")
@Produces("text/plain")
public String morning(
@PathParam("name") String name,
@QueryParam("drink") String drink) {
String greeting = "Good Morning " + name;
if (drink != null) {
greeting += ". Would you like some " + drink + "?";
}
return greeting;
}
}
. I changed the method hello() output but the response still remain "Good morning! test1": .
package com.liferaystack.application;
/**
* Copyright 2000-present Liferay, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.model.User;
import com.liferay.portal.kernel.service.UserLocalService;
import java.util.Collections;
import java.util.Set;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Application;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants;
/**
* @author Liferay
*/
@Component(
property = {
JaxrsWhiteboardConstants.JAX_RS_APPLICATION_BASE + "=/pippo",
JaxrsWhiteboardConstants.JAX_RS_NAME + "=Pippo"
},
service = Application.class
)
public class MyRestWebserviceApplication extends Application {
public Set<Object> getSingletons() {
return Collections.<Object>singleton(this);
}
@GET
@Produces("text/plain")
public String working() {
return "It works!";
}
@GET
@Path("/morning")
@Produces("text/plain")
public String hello() {
return "Good morning! after first deploy";
}
@GET
@Path("/mattina")
@Produces("text/plain")
public String helloGa() {
return "Good morning test2";
}
@GET
@Path("/buonamattina")
@Produces("text/plain")
public String buonamattina() {
return "BUONA MATTINA!";
}
@GET
@Path("/morning/{name}")
@Produces("text/plain")
public String morning(
@PathParam("name") String name,
@QueryParam("drink") String drink) {
String greeting = "Good Morning " + name;
if (drink != null) {
greeting += ". Would you like some " + drink + "?";
}
return greeting;
}
}
I run clean, build, deploy but changes not work.
I changed bundle-version in bnd.bnd many times. Only change that i can see is Bundle-Version in Back-End of Liferay:
Bundle-SymbolicName: my-rest-webservice
Bundle-Version: 1.1.4
Liferay-Configuration-Path: /configuration
Require-Capability:\
osgi.contract;\
filter:="(&(osgi.contract=JavaJAXRS)(version=2))"
-sources: true
来源:https://stackoverflow.com/questions/62046354/liferay-7-2-module-deploy-does-not-update-api