准备工作要搞好,对吧!(如下:)

  • firstcup项目代码文件下载链接:click me~
  • NetBeans IDE 8.2下载链接:点我~(ps:建议下载此版本,再安装过程中,要选择安装GlassFish服务器插件(至于Tomcat服务器插件要不要安装,随你);高版本的NetBeans IDE 9.x 或10.x 已默认不自带安装Glassfish 服务器插件。)
  • glassfish-5.0-web.zip
  • apache-maven-3.6.0-bin.zip

ps:配置环境变量已在其他博文中描述。

  1. 通过NetBeans IDE 8.2实现firstcup 项目部署

①文件(F)--->打开项目(E)

②选择你下载的firstcup解压后的路径:

 

③此时会看到“项目”栏中有了"firstcup"项目:

 

④鼠标右击 “firstcup”  项目--->清理并构建 :

 

⑤build 成功信息:

 

⑥此时项目文件里多了target子文件夹,并且target文件夹里面多了 firstcup-war.war 文件

 

⑦启动GlassFish服务器:

 

⑧可以看到输出栏中的Java DB数据库进程信息和GlassFish服务器启动的加载信息:

 

⑨打开管理员界面,部署刚才已build的firstcup-war.war文件:

 

⑩启动部署到GlassFish服务器上的项目:

 

最后运行结果如下:

2.通过NetBeans IDE 8.2实现firstcup 项目部署:

命令:asadmin   deploy   你的war项目文件所在的父目录\firstcup-war.war

但是出现如下错误:

remote  failure:  Error  occurred  during  deployment:  Exception  while  deploying  the  app  [firstcup-war]  :  Exception  [EclipseLink-4002]  (Eclipse  Persistence  Services  -  2.7.0.v20170811-d680af5):  org.eclipse.persistence.exceptions.DatabaseException

Internal  Exception:  java.sql.SQLException:  Error  in  allocating  a  connection.  Cause:  Connection  could  not  allocated  because:  java.net.ConnectionException:  连接到端口  1,527  上的服务器  localhost  时出错,消息为  Connection  refused:  connect。

Error  Code:  0.  Please  see  server.log  for  more  details.

 

原因: