Some basic functions of the online mall have been completed one after another. Although there are still many places to be improved, they will not affect the deployment and release of the project. We can play it first. This section mainly introduces the application of domain name space and the deployment and release process of the project.
1. Application for domain name space
As a great silk, I definitely don’t have the money to buy a domain name space. Naturally, I thought of applying for a free domain name space. Now there are many free domain name spaces. I applied for a 15-day trial period on Fujia JSP Technology.com. You can also apply for a play. Anyway, as a study, this is enough. Of course, if you want to do it for a long time, you will definitely have to pay. I took a few pictures of the registration process, as follows:
Then, the next step is finally activated as follows:
It is recommended to record the above information in a txt document, especially the domain name and some temporary application information. Because it is not used for a long time, you may not pay attention to it. Log in the next day and find that you may even forget the simplest login username and password... You must have the habit of recording important information at any time, you must have the habit of recording important information at any time, and you must have the habit of recording important information at any time. Say important things three times, you understand~
Then click to enter the jsp control panel, which contains a lot of information related to the account you applied for. You can check it out. Our project deployment is also deployed here later. as follows:
There are several more important information to record, such as: the domain name needs to be mentioned, the WEB directory , this is a directory after our project was finally deployed to the server. Remember the server's IP , and you will know what it is useful later.
At this point, we have applied for a free use space for 15 days, and he has also sent a domain name and a database. Next, we have to start deploying our own project.
2. Project deployment and release
Although we have applied for the domain name space, we can't just throw our project directly. First of all, we must not throw the project's source code directly. Secondly, even if the source code is still up, we can run away if we are sure? The answer is certainly not possible, and some local projects need to be changed. Next, let me explain in detail what needs to be modified in this project.
2.1 Local project + local database test
When we applied just now, he gave us the WEB directory, which is very important. That is to say, when our project is deployed to its server, there is a ROOT directory under the directory he gave. This ROOT is the default root directory. If we throw the code we want to pass directly into the ROOT, we can directly access it with http://域名/ . If there are other subdirectories, you need to use http://域名/子目录/ to access it.
So, first we have to test locally, throw the project code into the local tomcat ROOT, can it run through, first re-deploy the project E_shop (my project name), then turn on the tomcat server, and then you will see that there are ROOT and E_shop directories in the tomcat directory/webapps/ directory. Everyone on earth knows this, then turn off tomcat, copy and paste all the things in E_shop into ROOT (turn off tomcat first and copy and paste, otherwise there may be an error, mine), and then kill the E_shop deployed under the tomcat server (it is OK if you don't kill it~), restart tomcat, and then enter: http://localhost:8080/E_shop/index.jsp hangs up because I just killed E_shop under tomcat (it can be accessed if it is not killed). Enter http://localhost:8080/index.jsp to access it normally, which means that I threw the original E_shop into the ROOT and can be accessed directly (because index.jsp can be omitted). This means there is no problem with this local test.
[Note] The projects under the tomcat directory are all class files and some jsp files, and there is no source java files. So if we upload them using FTP later, we will also pass all files under the project directory under the tomcat.
2.2 Local project + remote database testing
Okay, it was normal to test locally just now, and this has nothing to do with remote. Now we are going to use remote database to test. This remote database is the database he sent when he was just registered, including the database name and username and password used for the connection. Have you just recorded it~~?
When we develop with MyEclipse, we will use the DB Browser window and the SQL Result window. This is very convenient for us to connect the database and view the data in the database in MyEclipse (if we don’t know these two gadgets, we can take a look at the integration of Struts2, Hibernate4 and Spring4). We create a new connection in DB Browser, as follows:
We can see that the new connection we created here is to connect to the remote database he just provided to us. The url, username and password are all given to us by him. After the connection is successful, we need to test whether we can insert the data in our own database into this remote database. So I copied all the contents of the shop.sql file I designed into the newly created remote.sql, open remote.sql to connect to the Remote database driver we just created, and execute all the commands in the SQL file. If you can see in the SQL Result window that the same information as the original is inserted into the database, it means that the connection is successful and can be used normally.
Okay, the remote database is connected. The next thing to do is to modify the configuration file connecting to the database. Because our current local configuration file is connected to the local database, it is definitely not possible. After we deploy the project, it should automatically connect to the remote database, and the data reading and writing in the remote database in the future. Let's first look at the local database connection configuration file conn.properties:
dataSource=com.mchange.v2.c3p0.ComboPooledDataSource
driverClass=com.MySQL.jdbc.Driver
jdbcUrl=jdbc:mysql://localhost:3306/shop
user=root
password=root
Let's create a new remote.properties:
dataSource=com.mchange.v2.c3p0.ComboPooledDataSource
driverClass=com.mysql.jdbc.Driver
jdbcUrl=jdbc:mysql://115.238.249.172:3306/sq_eson
user=sq_eson
password=squ138
The basic parameters are all given to us by him, so that we can connect to the remote database and then modify the configuration in beans.xml:
<bean> <property name="locations"> <array> <!-- <value>classpath:conn.properties</value> --> <value>classpath:remote.properties</value> </array> </property> </bean>
At this point, you can understand the benefits of using properties configuration files. If you want to modify, you only need to modify the configuration files, and you don’t need to change the original things in the program on a large scale! Also, I would like to give a friendly reminder to try not to delete the original, such as the conn.properties file, because if the project needs to be changed later, it must be local during testing, and try not to delete it randomly. If it can be commented, comment out. If it does not affect it, don’t delete it unless it has to be deleted.
After the above modification, the project will automatically connect to the remote database after it is started. Then we open the tomcat server, open the home page, select a product, click to buy, of course there is no need to pay, click to buy, and it will be put into the database after clicking to buy. We can check whether there is a new shopping information in the remote database to determine whether it is normal. At this point, we completed the local project + remote database test, and we are going down without any problem.
2.3 Modify the original dead things in the local project
This is easy to understand, because when we write our own project, in order to facilitate testing, some places directly give data to test whether the function is normal. This has to be determined based on my actual project. For example, in my online mall project, I used to send emails and text messages and send text messages myself, so now I have to generate a user in the user table, fill in my email and mobile phone number. After the deployment, I use this user to log in to purchase, and then I can receive emails and text messages myself. Also, after the purchase, I have to update the order status to be paid. I used to test it casually, and I need to pay attention to these details. Also, the price of a product is 0.01 yuan, because after deployment, you have to test whether the function is normal. If the price is hundreds or thousands, I have already fainted in the toilet. In addition, there is another place in my project, that is, after adding the product, the product picture will be saved to an address on the server, and we have to change it to the corresponding directory on the remote server:
#Comment out the original basePath
#basePath=E/://web//apache-tomcat-8.0.26//webapps//E_shop
basePath=E/://www1//eson-0b44449e54c855b40154dbd2b0b906d9//webapps//ROOT//
filePath=//files
bankImagePath=//files//bankImages
Therefore, during development, if a certain place needs to be modified later, it is for testing and manual parameters to be given, so it is best to have a comment in the corresponding position to facilitate modification during later deployment, otherwise it will definitely fall out later.
3. Upload project files
The preparations are all done, and the next step is to upload the project files. Here we mainly introduce two upload methods: FTP upload and online upload on the provider's website.
3.1 FTP upload
FTP is a file upload protocol. You can upload files to a specified location or download files from a specified location (providing a free download address, which contains a cracking key). FTP upload is relatively simple, but it may take a longer time. It is recommended to pass it bit by bit, so that data is not easily lost. Next, I will introduce the FTP upload process:
Copy a copy of the project deployed in the tomcat directory to the desktop. For example, my project is E_shop. Open the FTP upload software, select desktop/E_shop on the left, locate the project directory and configure the address to be uploaded on the right, as shown in the figure below, and then drag the left file to the window on the right to complete the upload
Let’s take a look at the FTP upload interface, and mainly look at the connection in the third step above:
Once connected, you can upload it. Note: After connecting, the right window should be located in the ROOT directory, and you cannot be wrongly located. Then wait slowly for the transmission, and then directly access the domain name provided when applying.
3.2 Upload online
After just registering, you can upload it in the jsp control panel, but this requires us to export the project as a war package first, and then upload this war package. It is very simple to export the project as a war package. Click File->export->into war in MyEclipse, and then select the location to export (select the desktop), and you can export it smoothly. Then let’s take a look at the online deployment provided by Fujia JSP technology as follows:
Next, you can directly use the domain name to access the newly deployed project. When the webpage pops up, the pleasure is not given by Tokyo Heat~~Of course, you can also not pass on the entire project project, or even just pass on an index.jsp to play with it, see the effect, and go through the process~
Okay, that’s all for the application of domain name space and the deployment and release of projects! I will briefly improve some places, and I can almost upload the source code.
Original address: http://blog.csdn.net/eson_15/article/details/51484247
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.