Deployment of JAVAWEB:SSH projects on Sinaapp and binding of domain names

Source: Internet
Author: User
Tags utf 8

1. First create a new application in the SAE

When creating an app, we need to fill out a level two domain name, such as XXXXXX. In the "Development language" column, select Java and select the corresponding JVM level.

2. View application Information
We can view the current app's configuration on the "app home page", such as:


Figure 1 Applied Information

Among them, we must note that the access key and secret key in this two, when access to MySQL, they are the user name and password

3. Managing MySQL
In the Service management item, select MySQL subkey, we can manage MySQL, the simplest is to use phpMyAdmin to manage the database, 2


Figure 2

After we get in, we can manage MySQL, as shown in our MySQL address and port number, and the name of the database. The name of the database is app_xxxxxx, where XXXXXX is the name of the app. Then, we can build the database table under the current database.


Figure 3

We can use SQL to create corresponding database tables, for example, the database table for this SSH project is:

/*navicat MySQL Data transfersource server:localhost_3306source Server version:50027source Host:lo         Calhost:3306source database:sshmysqltarget Server type:mysqltarget server Version:50027file Encoding : 65001date:2015-01-11 10:43:42*/set foreign_key_checks=0;--------------------------------Table structure for bbscom ment------------------------------DROP TABLE IF EXISTS ' bbscomment '; CREATE TABLE ' bbscomment ' (' uuid ' varchar) NOT NULL, ' messageid ' varchar (+) NOT NULL, ' username ' varchar (+) not N ULL, ' content ' varchar (+) NOT null, ' touser ' varchar (+) default NULL, ' agree ' int (8) default NULL, ' Disagree ' Int (8 Default NULL, ' date ' varchar (+) NOT NULL, ' top ' int (8) default NULL, ' Reserve1 ' varchar (+) default NULL, ' Reserve  2 ' varchar (+) default NULL, PRIMARY KEY (' uuid ')) engine=innodb default Charset=utf8;-------------------------------- Table structure for bbsmessage------------------------------DROP table IF EXIsts ' Bbsmessage '; CREATE TABLE ' bbsmessage ' (' uuid ' varchar) NOT NULL, ' username ' varchar (+) not NULL, ' content ' varchar (+) not NU LL, ' imageheadurl ' varchar () default NULL, ' agree ' int (8) default NULL, ' Disagree ' int (8) default NULL, ' share ' int (8) Default NULL, ' address ' varchar (+) default NULL, ' date ' varchar (+) NOT NULL, ' top ' int (8) default NULL, ' Phonemo  Del ' varchar (+) default NULL, ' Reserve1 ' varchar (+) default NULL, ' Reserve2 ' varchar (+) default NULL, PRIMARY KEY (' uuid ')) Engine=innodb DEFAULT Charset=utf8;--------------------------------Table structure for student--------------------- ---------DROP TABLE IF EXISTS ' student '; CREATE TABLE ' student ' (' ID ' varchar (*) NOT NULL, ' name ' varchar (+) NOT NULL, ' course ' varchar (") ' NOT null, ' score ' Int (one) not null, ' remarks ' varchar (+) default NULL, PRIMARY KEY (' id ')) engine=innodb default Charset=utf8;------ --------------------------Table structure for userinfo------------------------------DROP TABLE IF EXISTS ' userinfo '; CREATE TABLE ' userinfo ' (' uuid ' varchar) NOT NULL, ' username ' varchar (+) NOT NULL, ' password ' varchar (+) NOT NULL , ' imageheadurl ' varchar default NULL, ' Level ' int (8) is not NULL, ' registertime ' varchar (+) NOT null, ' Reserve1 ' V Archar (+) default NULL, ' Reserve2 ' varchar ($) default NULL, PRIMARY KEY (' uuid ')) Engine=innodb default Charset=utf 8;

4. Deploying the SSH Project
Before we deploy, we need to be aware that:
4.1. Configuration of the database
This is primarily the configuration of the URL and user name password:

Jdbc.mysql.url=jdbc:mysql://w.rdc.sae.sina.com.cn:3307/app_xxxxxxjdbc.mysql.username=access Keyjdbc.mysql.password=secret Key

4.2. Configuration of database connections
After uploading the code for the first time, "Could not open Hibernate Session for Transaction" error appears, in order to solve this problem, we need to add configuration information in the database connection pool

<!--creating a MySQL JDBC data source--><bean id= "C3p0datasource" class= "Com.mchange.v2.c3p0.ComboPooledDataSource" Destroy-method= "Close" ><property name= "Driverclass" value= "${jdbc.mysql.driver}"/><property name= " Jdbcurl "value=" ${jdbc.mysql.url} "/><property name=" user "value=" ${jdbc.mysql.username} "/><property Name= "Password" value= "${jdbc.mysql.password}"/><property name= "Testconnectiononcheckin" value= "true"/> <property name= "Testconnectiononcheckout" value= "true"/></bean>

The thing to note here is Testconnectiononcheckin and testconnectiononcheckout.


In addition, there is a need to note that the sessionfactory,
Increase
<prop key= "Hibernate.autoreconnect" >true</prop>
Configuration
For example:

<bean id= "Sessionfactory" class= "Org.springframework.orm.hibernate4.LocalSessionFactoryBean" ><property Name= "DataSource" ref= "C3p0datasource"/><property name= "hibernateproperties" ><props>    <prop key= "Hibernate.autoreconnect" >true</prop><prop key= "Hibernate.show_sql" >false</prop>< Prop key= "Hibernate.dialect" >org.hibernate.dialect.mysqldialect</prop><prop key= "Current_session_ Context_class ">thread</prop></props></property>...</bean>

4.3. It is also important to note that hibernate's. hbm.xml file, if it is myeclipse automatically generated, will have a field called "Catalog",
It is a good idea to delete the field. Because the database name that is debugged locally and the database name on the SAE may be different.


5. Package Upload
Once the above configuration is complete, use MyEclipse to export the project to a. War package with the name of the app, such as Xxxxxx.war, then upload to SAE space


Figure 4

After a while (half a minute), we can access the XXXXXX.sinaapp.com to see if the deployed project will run successfully.

At this point, the SSH project was successfully deployed on the Sinaapp.


6. Binding of domain names

Sina domain name is two level domain name, then how do we bind the level two domain name with the first level domain name that we buy?

I generally buy the domain name, after buying the domain name, the need for personal identity registration and authentication, and then you can parse.

First in the SAE "Application Home", the independent domain name, click on the "binding" Independent Domain name: Enter the domain name that needs to be bound, then the following dialog box will appear:


Figure 5

Note that the content that is circled is what we used in the domain name resolution.

Open the resolution page of WAN, and add the correct CNAME information and a record information on the parsing page according to the SAE's prompt.

For example, here is an analysis of one of my domain names:


Domain name bindings generally take effect around 1 minutes.


Not for commercial purposes without permission


Deployment of JAVAWEB:SSH projects on Sinaapp and binding of domain names

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.