解決したいこと
エラー無く正常にデプロイさせる
発生している問題・エラーメッセージ
※一部省略
パッケージorg.apache.commons.ioは存在しません
パッケージcom.liferay.portal.utilは存在しません
パッケージcom.liferay.util.bridgesは存在しません
シンボル: 変数PortalUtil
場所: クラスRelatedFilesPortlet
シンボルを見つけられません
シンボル: 変数FileUtils
場所: クラスRelatedFilesPortlet
シンボルを見つけられません
ソースコード
※参考元:http://www.codeyouneed.com/liferay-portlet-file-upload-tutorial/
import java.io.File; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; import org.apache.commons.io.FileUtils; import com.liferay.portal.kernel.upload.UploadPortletRequest; import com.liferay.portal.util.PortalUtil; import com.liferay.util.bridges.mvc.MVCPortlet; public class RelatedFilesPortlet extends MVCPortlet { private final static int ONE_GB = 1073741824; private final static String baseDir = "/tmp/uploaded/"; private final static String fileInputName = "fileupload"; public void upload(ActionRequest request, ActionResponse response) throws Exception { UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(request); long sizeInBytes = uploadRequest.getSize(fileInputName); if (uploadRequest.getSize(fileInputName) == 0) { throw new Exception("Received file is 0 bytes!"); } // Get the uploaded file as a file. File uploadedFile = uploadRequest.getFile(fileInputName); String sourceFileName = uploadRequest.getFileName(fileInputName); // Where should we store this file? File folder = new File(baseDir); // Check minimum 1GB storage space to save new files... if (folder.getUsableSpace() < ONE_GB) { throw new Exception("Out of disk space!"); } // This is our final file path. File filePath = new File(folder.getAbsolutePath() + File.separator + sourceFileName); // Move the existing temporary file to new location. FileUtils.copyFile(uploadedFile, filePath); } }
試したこと
対象のLiferay Module Projectを右クリック>Build Path>Configure Build Path...>
Libraries>Add External JARsにて下記を追加
- commons-io-2.5.jar
- liferay-portal-service-6.1.1.jar
- org.apache.commons.io.jar
- util-bridges-6.1.2.jar
環境
- liferay-ide-eclipse-windows-x64-3.1.0-b1-201705141336
- jdk-8u131-windows-x64
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。