.Net 码农搭使用 Intellij ideal 搭Java Maven + Spring + Mybatis 客户端框架(四)

如何配一个非WebApp的客户端服务,其实主要就是在客户端程序中是如何替换web.xml 的:

新一个Maven quickstart项目

 

 

 

 

完成后等待Maven生成项目结构:

 

新增目录和文件如下:

 

spring.xml 文件内容如下:

<?xmlversion="1.0"encoding="UTF-8"?>
<beansxmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsd">

<importresource="applicationContext-dao.xml"></import>
<context:component-scanbase-package="com.springdemo.services"/>

</beans>

 

 

 

其它请参考

.Net 码农搭使用 Intellij ideal 搭Java Maven + Spring + Spring MVC + Mybatis 框架

 

标记文件夹类型:

 

 

 

这里与WebApp的主要区是要在 App.java 启动程序里引用spring.xml配置

 

 

 

最后pom.xml的配置上要在web-app节点下新增一下启动方法入口:

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformerimplementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.springdemo.App</mainClass>

</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

 

 

 完整项目包:

 https://files.cnblogs.com/files/Yu-weiz/AppSpringDemo.zip

转载于:https://www.cnblogs.com/Yu-weiz/p/8005940.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值