.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

posted on 2017-12-08 16:19  Yu-weiz  阅读(157)  评论(0)    收藏  举报

导航